├── README.md ├── proj.win8.1-universal └── libjscocos2d │ ├── libjscocos2d.Windows │ └── libjscocos2d.Windows.vcxproj.filters │ ├── libjscocos2d.WindowsPhone │ └── libjscocos2d.WindowsPhone.vcxproj.filters │ └── libjscocos2d.Shared │ └── targetver.h ├── manual ├── localstorage │ ├── js_bindings_system_functions.h │ ├── js_bindings_system_functions_registration.h │ ├── js_bindings_system_registration.h │ ├── js_bindings_system_functions.cpp │ └── js_bindings_system_registration.cpp ├── chipmunk │ ├── js_bindings_chipmunk_registration.h │ ├── js_bindings_chipmunk_auto_classes_registration.h │ ├── js_bindings_chipmunk_registration.cpp │ ├── js_bindings_chipmunk_auto_classes.h │ └── js_bindings_chipmunk_manual.h ├── network │ ├── jsb_websocket.h │ ├── jsb_socketio.h │ └── XMLHTTPRequest.h ├── jsb_opengl_registration.h ├── ui │ └── jsb_cocos2dx_ui_manual.h ├── cocostudio │ ├── jsb_cocos2dx_studio_manual.h │ ├── jsb_cocos2dx_studio_conversions.h │ └── jsb_cocos2dx_studio_conversions.cpp ├── 3d │ └── jsb_cocos2dx_3d_manual.h ├── js_bindings_opengl.h ├── jsb_event_dispatcher_manual.h ├── jsb_opengl_manual.h ├── cocosbuilder │ ├── cocosbuilder_specifics.hpp │ └── js_bindings_ccbreader.h ├── spine │ └── jsb_cocos2dx_spine_manual.h ├── extension │ └── jsb_cocos2dx_extension_manual.h ├── js_bindings_core.h ├── platform │ ├── ios │ │ └── JavaScriptObjCBridge.h │ └── android │ │ └── CCJavascriptJavaBridge.h ├── spidermonkey_specifics.h ├── js_bindings_core.cpp ├── jsb_helper.h └── js_bindings_config.h ├── script ├── chipmunk │ └── jsb_chipmunk_constants.js ├── 3d │ └── jsb_cocos2d_3d_ext.js ├── ccui │ ├── jsb_ccui_deprecated.js │ ├── jsb_ccui_property_impls.js │ └── jsb_ccui_create_apis.js ├── debugger │ ├── README.md │ └── DevToolsUtils.js ├── studio │ ├── jsb_studio_boot.js │ ├── jsb_studio_property_apis.js │ └── jsb_studio_create_apis.js ├── jsb_spine.js ├── extension │ ├── jsb_ext_create_apis.js │ └── jsb_ext_property_apis.js ├── jsb_cocos2d_constants.js ├── jsb.js ├── jsb_deprecated.js ├── jsb_pool.js ├── physicsSprite │ └── jsb_physicsSprite.js ├── jsb_loaders.js └── jsb_debugger.js ├── .gitignore ├── proj.ios_mac └── cocos2d_js_bindings.xcodeproj │ └── xcshareddata │ └── xcschemes │ ├── libjscocos2d Mac.xcscheme │ └── libjscocos2d iOS.xcscheme ├── CMakeLists.txt ├── proj.android └── Android.mk └── auto ├── jsb_cocos2dx_spine_auto.hpp ├── jsb_cocos2dx_3d_extension_auto.hpp └── jsb_cocos2dx_builder_auto.hpp /README.md: -------------------------------------------------------------------------------- 1 | # js-bindings 2 | 3 | This repo is used for js bindings. 4 | -------------------------------------------------------------------------------- /proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /manual/localstorage/js_bindings_system_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 4 | * Script version: v0.5 5 | */ 6 | #include "js_bindings_config.h" 7 | #include "jsapi.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | bool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp); 13 | bool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp); 14 | bool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | 21 | //#endif // JSB_INCLUDE_SYSTEM 22 | -------------------------------------------------------------------------------- /script/chipmunk/jsb_chipmunk_constants.js: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c chipmunk_jsb.ini" on 2013-03-05 4 | * Script version: v0.6 5 | */ 6 | 7 | var cp = cp || {}; 8 | cp.ALLOW_PRIVATE_ACCESS = 0x1; 9 | cp.ALL_LAYERS = 0xffffffff; 10 | cp.BUFFER_BYTES = 0x8000; 11 | cp.CIRCLE_SHAPE = 0x0; 12 | cp.HASH_COEF = 0xc75f71e1; 13 | cp.MAX_CONTACTS_PER_ARBITER = 0x4; 14 | cp.NO_GROUP = 0x0; 15 | cp.NUM_SHAPES = 0x3; 16 | cp.POLY_SHAPE = 0x2; 17 | cp.SEGMENT_SHAPE = 0x1; 18 | cp.USE_CGPOINTS = 0x1; 19 | cp.USE_DOUBLES = 0x0; 20 | cp.VERSION_MAJOR = 0x6; 21 | cp.VERSION_MINOR = 0x1; 22 | cp.VERSION_RELEASE = 0x1; 23 | -------------------------------------------------------------------------------- /manual/localstorage/js_bindings_system_functions_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 4 | * Script version: v0.5 5 | */ 6 | #include "../js_bindings_config.h" 7 | //#ifdef JSB_INCLUDE_SYSTEM 8 | 9 | //#include "LocalStorage.h" 10 | JS_DefineFunction(_cx, system, "getItem", JSB_localStorageGetItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 11 | JS_DefineFunction(_cx, system, "removeItem", JSB_localStorageRemoveItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 12 | JS_DefineFunction(_cx, system, "setItem", JSB_localStorageSetItem, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 13 | 14 | 15 | //#endif // JSB_INCLUDE_SYSTEM 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore thumbnails created by windows 2 | Thumbs.db 3 | 4 | # Ignore files build by Visual Studio 5 | *.obj 6 | *.exe 7 | *.pdb 8 | *.aps 9 | *.vcproj.*.user 10 | *.vcxproj.user 11 | *.vspscc 12 | *_i.c 13 | *.i 14 | *.icf 15 | *_p.c 16 | *.ncb 17 | *.suo 18 | *.tlb 19 | *.tlh 20 | *.bak 21 | *.cache 22 | *.ilk 23 | *.log 24 | [Bb]in 25 | [Dd]ebug/ 26 | [Dd]ebug.win32/ 27 | *.sbr 28 | *.sdf 29 | obj/ 30 | [Rr]elease/ 31 | [Rr]elease.win32/ 32 | _ReSharper*/ 33 | [Tt]est[Rr]esult* 34 | ipch/ 35 | *.opensdf 36 | Generated Files 37 | AppPackages 38 | 39 | # Ignore files build by ndk and eclipse 40 | libs/ 41 | bin/ 42 | obj/ 43 | gen/ 44 | assets/ 45 | local.properties 46 | 47 | # Ignore files build by airplay and marmalade 48 | build_*_xcode/ 49 | build_*_vc10/ 50 | 51 | # Ignore files build by Xcode 52 | *.mode*v* 53 | *.pbxuser 54 | *.xcbkptlist 55 | *.xcworkspacedata 56 | *.xcuserstate 57 | *.xccheckout 58 | xcschememanagement.plist 59 | .DS_Store 60 | ._.* 61 | xcuserdata/ 62 | DerivedData/ 63 | 64 | # Ignore vim swaps 65 | *.swp 66 | *.swo 67 | 68 | # Cmake files 69 | CMakeCache.txt 70 | CMakeFiles 71 | Makefile 72 | cmake_install.cmake 73 | CMakeLists.txt.user 74 | 75 | *.jsc 76 | -------------------------------------------------------------------------------- /manual/localstorage/js_bindings_system_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | 25 | #ifndef __JSB_SYSTEM_REGISTRATION 26 | #define __JSB_SYSTEM_REGISTRATION 27 | 28 | void jsb_register_system( JSContext *globalC, JS::HandleObject globalO); 29 | 30 | #endif // __JSB_CHIPMUNK_REGISTRATION 31 | -------------------------------------------------------------------------------- /manual/chipmunk/js_bindings_chipmunk_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | 25 | #ifndef __JSB_CHIPMUNK_REGISTRATION 26 | #define __JSB_CHIPMUNK_REGISTRATION 27 | 28 | void jsb_register_chipmunk( JSContext *globalC, JS::HandleObject globalO); 29 | 30 | #endif // __JSB_CHIPMUNK_REGISTRATION 31 | -------------------------------------------------------------------------------- /manual/network/jsb_websocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by James Chen 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __jsb_websocket__ 25 | #define __jsb_websocket__ 26 | 27 | #include "jsapi.h" 28 | #include "jsfriendapi.h" 29 | 30 | void register_jsb_websocket(JSContext* cx, JS::HandleObject global); 31 | 32 | #endif /* defined(__jsb_websocket__) */ 33 | -------------------------------------------------------------------------------- /manual/jsb_opengl_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __JSB_OPENGL_REGISTRATION 25 | #define __JSB_OPENGL_REGISTRATION 26 | #include "jsb_opengl_functions.h" 27 | 28 | void JSB_register_opengl( JSContext *globalC, JS::HandleObject globalO); 29 | 30 | #endif // __JSB_OPENGL_REGISTRATION 31 | -------------------------------------------------------------------------------- /manual/network/jsb_socketio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by Chris Hannon 2014 http://www.channon.us 3 | * Copyright (c) 2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __jsb_socketio__ 25 | #define __jsb_socketio__ 26 | 27 | #include "jsapi.h" 28 | #include "jsfriendapi.h" 29 | 30 | void register_jsb_socketio(JSContext* cx, JS::HandleObject global); 31 | 32 | #endif /* defined(__jsb_socketio__) */ 33 | -------------------------------------------------------------------------------- /manual/ui/jsb_cocos2dx_ui_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by LinWenhai on 17/11/13. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __jsb_cocos2dx_ui_manual__ 25 | #define __jsb_cocos2dx_ui_manual__ 26 | 27 | #include "jsapi.h" 28 | #include "jsfriendapi.h" 29 | 30 | void register_all_cocos2dx_ui_manual(JSContext* cx, JS::HandleObject global); 31 | 32 | #endif /* defined(__jsb_cocos2dx_ui_manual__) */ 33 | -------------------------------------------------------------------------------- /manual/cocostudio/jsb_cocos2dx_studio_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by LinWenhai on 20/10/13. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __jsb_cocos2dx_studio_manual__ 25 | #define __jsb_cocos2dx_studio_manual__ 26 | 27 | #include "jsapi.h" 28 | #include "jsfriendapi.h" 29 | 30 | void register_all_cocos2dx_studio_manual(JSContext* cx, JS::HandleObject global); 31 | 32 | #endif /* defined(__jsb_cocos2dx_studio_manual__) */ 33 | -------------------------------------------------------------------------------- /script/3d/jsb_cocos2d_3d_ext.js: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2008-2010 Ricardo Quesada 3 | Copyright (c) 2011-2012 cocos2d-x.org 4 | Copyright (c) 2013-2014 Chukong Technologies Inc. 5 | 6 | http://www.cocos2d-x.org 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | ****************************************************************************/ 26 | 27 | jsb.ParticleSystem3D.prototype._setBlendFunc = jsb.ParticleSystem3D.prototype.setBlendFunc; 28 | jsb.ParticleSystem3D.prototype.setBlendFunc = templateSetBlendFunc; -------------------------------------------------------------------------------- /manual/chipmunk/js_bindings_chipmunk_auto_classes_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 4 | * Script version: v0.3 5 | */ 6 | #include "js_bindings_config.h" 7 | #ifdef JSB_INCLUDE_CHIPMUNK 8 | 9 | JSB_cpConstraint_createClass(cx, chipmunk, "Constraint"); 10 | JSB_cpGrooveJoint_createClass(cx, chipmunk, "GrooveJoint"); 11 | JSB_cpSimpleMotor_createClass(cx, chipmunk, "SimpleMotor"); 12 | JSB_cpPivotJoint_createClass(cx, chipmunk, "PivotJoint"); 13 | JSB_cpPinJoint_createClass(cx, chipmunk, "PinJoint"); 14 | JSB_cpSlideJoint_createClass(cx, chipmunk, "SlideJoint"); 15 | JSB_cpGearJoint_createClass(cx, chipmunk, "GearJoint"); 16 | JSB_cpDampedRotarySpring_createClass(cx, chipmunk, "DampedRotarySpring"); 17 | JSB_cpDampedSpring_createClass(cx, chipmunk, "DampedSpring"); 18 | JSB_cpRatchetJoint_createClass(cx, chipmunk, "RatchetJoint"); 19 | JSB_cpRotaryLimitJoint_createClass(cx, chipmunk, "RotaryLimitJoint"); 20 | JSB_cpArbiter_createClass(cx, chipmunk, "Arbiter"); 21 | JSB_cpSpace_createClass(cx, chipmunk, "Space"); 22 | JSB_cpBody_createClass(cx, chipmunk, "Body"); 23 | JSB_cpShape_createClass(cx, chipmunk, "Shape"); 24 | JSB_cpCircleShape_createClass(cx, chipmunk, "CircleShape"); 25 | JSB_cpSegmentShape_createClass(cx, chipmunk, "SegmentShape"); 26 | JSB_cpPolyShape_createClass(cx, chipmunk, "PolyShape"); 27 | JSB_cpSegmentQueryInfo_createClass(cx, chipmunk, "SegmentQueryInfo"); 28 | JSB_cpNearestPointQueryInfo_createClass(cx, chipmunk, "NearestPointQueryInfo"); 29 | JSB_cpSplittingPlane_createClass(cx, chipmunk, "SplittingPlane"); 30 | #endif // JSB_INCLUDE_CHIPMUNK 31 | -------------------------------------------------------------------------------- /manual/3d/jsb_cocos2dx_3d_manual.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2008-2010 Ricardo Quesada 3 | Copyright (c) 2011-2012 cocos2d-x.org 4 | Copyright (c) 2013-2014 Chukong Technologies Inc. 5 | 6 | http://www.cocos2d-x.org 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | ****************************************************************************/ 26 | #ifndef __jsb_cocos2dx_3d_manual_h__ 27 | #define __jsb_cocos2dx_3d_manual_h__ 28 | 29 | #include "jsapi.h" 30 | 31 | void register_all_cocos2dx_3d_manual(JSContext *cx, JS::HandleObject global); 32 | 33 | #endif -------------------------------------------------------------------------------- /script/ccui/jsb_ccui_deprecated.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | // Deprecated functions 24 | 25 | var cc = cc || {}; 26 | 27 | (function() { 28 | 29 | ccui.Text.prototype.setText = function(text){ 30 | logW("ccui.Text.setText", "ccui.Text.setString"); 31 | this.setString(text); 32 | }; 33 | 34 | ccui.Text.prototype.getStringValue = function(){ 35 | logW("ccui.Text.getStringValue", "ccui.Text.getString"); 36 | return this.getString(); 37 | }; 38 | 39 | })(); 40 | -------------------------------------------------------------------------------- /manual/js_bindings_opengl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | #include "ScriptingCore.h" 24 | #include "cocos2d_specifics.hpp" 25 | 26 | NS_CC_BEGIN 27 | 28 | class GLNode : public cocos2d::Node 29 | { 30 | public: 31 | void draw(Renderer *renderer, const Mat4& transform, uint32_t flags) override; 32 | protected: 33 | void onDraw(Mat4 &transform, uint32_t flags); 34 | cocos2d::CustomCommand _customCommand; 35 | }; 36 | 37 | NS_CC_END 38 | 39 | void js_register_cocos2dx_GLNode(JSContext *cx, JS::HandleObject global); 40 | -------------------------------------------------------------------------------- /manual/cocostudio/jsb_cocos2dx_studio_conversions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by Huabin LING on 21/1/15. 3 | * Copyright (c) 2015 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __cocos2d_js_bindings__jsb_cocos2dx_studio_conversions__ 25 | #define __cocos2d_js_bindings__jsb_cocos2dx_studio_conversions__ 26 | 27 | #include "jsapi.h" 28 | 29 | namespace cocostudio 30 | { 31 | namespace timeline 32 | { 33 | struct AnimationInfo; 34 | } 35 | } 36 | 37 | extern jsval animationInfo_to_jsval(JSContext* cx, const cocostudio::timeline::AnimationInfo& v); 38 | extern bool jsval_to_animationInfo(JSContext* cx, JS::HandleValue vp, cocostudio::timeline::AnimationInfo* ret); 39 | 40 | #endif /* defined(__cocos2d_js_bindings__jsb_cocos2dx_studio_conversions__) */ 41 | -------------------------------------------------------------------------------- /manual/jsb_event_dispatcher_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __cocos2d_js_bindings__jsb_event_dispatcher__ 24 | #define __cocos2d_js_bindings__jsb_event_dispatcher__ 25 | 26 | #include "jsapi.h" 27 | #include "jsfriendapi.h" 28 | 29 | bool js_EventListenerTouchOneByOne_create(JSContext *cx, uint32_t argc, jsval *vp); 30 | bool js_EventListenerTouchAllAtOnce_create(JSContext *cx, uint32_t argc, jsval *vp); 31 | bool js_EventListenerKeyboard_create(JSContext *cx, uint32_t argc, jsval *vp); 32 | bool js_EventListenerMouse_create(JSContext *cx, uint32_t argc, jsval *vp); 33 | bool js_EventListenerFocus_create(JSContext *cx, uint32_t argc, jsval *vp); 34 | 35 | #endif /* defined(__cocos2d_js_bindings__jsb_event_dispatcher__) */ 36 | -------------------------------------------------------------------------------- /manual/jsb_opengl_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | 25 | #ifndef __jsb_opengl_manual 26 | #define __jsb_opengl_manual 27 | 28 | #include "js_bindings_config.h" 29 | #ifdef JSB_INCLUDE_OPENGL 30 | 31 | //#include 32 | #include "jsapi.h" 33 | #include "jsfriendapi.h" 34 | 35 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 36 | #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) 37 | 38 | // compatible with iOS 39 | #define glClearDepthf glClearDepth 40 | #define glDepthRangef glDepthRange 41 | #ifndef glReleaseShaderCompiler 42 | #define glReleaseShaderCompiler() 43 | #endif 44 | 45 | #endif // __MAC_OS_X_VERSION_MAX_ALLOWED 46 | 47 | // forward declaration of new functions 48 | bool JSB_glGetSupportedExtensions(JSContext *cx, uint32_t argc, jsval *vp); 49 | 50 | 51 | #endif // JSB_INCLUDE_OPENGL 52 | 53 | #endif // __jsb_opengl_manual 54 | -------------------------------------------------------------------------------- /script/debugger/README.md: -------------------------------------------------------------------------------- 1 | Remote Debugging By Using FireFox 2 | ================================= 3 | 4 | Requirement 5 | ----------- 6 | 7 | * Firefox: From v24 8 | 9 | How To Use 10 | ---------- 11 | 12 | ### Prepare ### 13 | 14 | Please refer to https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging . 15 | 16 | ### Enable Debugger Support For Your JSB Project ### 17 | 18 | ``` 19 | bool AppDelegate::applicationDidFinishLaunching() 20 | { 21 | ... 22 | 23 | ScriptingCore* sc = ScriptingCore::getInstance(); 24 | sc->addRegisterCallback(register_all_cocos2dx); 25 | sc->addRegisterCallback(register_all_cocos2dx_extension); 26 | sc->addRegisterCallback(register_cocos2dx_js_extensions); 27 | sc->addRegisterCallback(jsb_register_chipmunk); 28 | sc->addRegisterCallback(register_all_cocos2dx_extension_manual); 29 | sc->addRegisterCallback(register_CCBuilderReader); 30 | sc->addRegisterCallback(jsb_register_system); 31 | sc->addRegisterCallback(JSB_register_opengl); 32 | 33 | sc->start(); 34 | 35 | #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) 36 | sc->enableDebugger(); // Enable debugger here 37 | #endif 38 | 39 | ... 40 | } 41 | ``` 42 | 43 | Run your game. 44 | 45 | ### Open Firefox And Follow The Step As Follows ### 46 | 47 | 48 | ![pic 1](https://lh5.googleusercontent.com/-HoxLGBdV2J0/UlZ7ZoFUjyI/AAAAAAAAADM/68GDaCQ1vP0/s0-I/Firefox-Remote-Debug01.jpg) 49 | ![pic 2](https://lh6.googleusercontent.com/-7FDIHAYsKAY/UlZ7Yf8W-pI/AAAAAAAAAFQ/joG0AymnuBk/s0-I/Firefox-Remote-Debug02.jpg) 50 | ![pic 3](https://lh4.googleusercontent.com/-idvnMRGcGy8/UlZ7Wj6DDuI/AAAAAAAAAC0/L9IVyHLNqeQ/s0-I/Firefox-Remote-Debug04.jpg) 51 | ![pic 4](https://lh6.googleusercontent.com/-YuZj7JGAtFE/UlZ9DDGDczI/AAAAAAAAAEQ/D2qIedjP5FU/s0-I/Firefox-Remote-Debug04.png.png) 52 | ![pic 5](https://lh3.googleusercontent.com/-cdIcNa3jT5c/UlZ9uapf3OI/AAAAAAAAAEg/MGq3vLHsauw/s0-I/Firefox-Remote-Debug05.png) 53 | ![pic 6](https://lh5.googleusercontent.com/-T79-o5ylJKI/UlZ_JJQe3MI/AAAAAAAAAE8/F63fSVxlJKs/s0-I/Firefox-Remote-Debug06.png) 54 | 55 | -------------------------------------------------------------------------------- /manual/cocosbuilder/cocosbuilder_specifics.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __JS_COCOSBUILDER_SPECIFICS_H__ 25 | #define __JS_COCOSBUILDER_SPECIFICS_H__ 26 | 27 | #include "../cocos2d_specifics.hpp" 28 | 29 | class JSCCBAnimationWrapper: public JSCallbackWrapper 30 | { 31 | public: 32 | JSCCBAnimationWrapper() {} 33 | virtual ~JSCCBAnimationWrapper() {} 34 | 35 | void animationCompleteCallback() 36 | { 37 | 38 | if(!_jsCallback.isNullOrUndefined() && !_jsThisObj.isNullOrUndefined()) 39 | { 40 | 41 | JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); 42 | JS::RootedValue retval(cx); 43 | 44 | JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET 45 | 46 | JS_CallFunctionValue(cx, JS::RootedObject(cx, _jsThisObj.toObjectOrNull()), JS::RootedValue(cx, _jsCallback), JS::HandleValueArray::empty(), &retval); 47 | } 48 | } 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /manual/localstorage/js_bindings_system_functions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 4 | * Script version: v0.5 5 | */ 6 | #include "js_bindings_system_functions.h" 7 | #include "js_bindings_config.h" 8 | #include "js_bindings_core.h" 9 | #include "js_manual_conversions.h" 10 | #include "ScriptingCore.h" 11 | #include "local-storage/LocalStorage.h" 12 | 13 | USING_NS_CC; 14 | 15 | // Arguments: char* 16 | // Ret value: const char* 17 | bool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp) { 18 | JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); 19 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); 20 | bool ok = true; 21 | std::string arg0; 22 | 23 | ok &= jsval_to_std_string( cx, args.get(0), &arg0 ); 24 | JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); 25 | std::string ret_val; 26 | 27 | localStorageGetItem(arg0, &ret_val); 28 | 29 | jsval ret_jsval = std_string_to_jsval(cx, ret_val); 30 | args.rval().set(ret_jsval); 31 | 32 | return true; 33 | } 34 | 35 | // Arguments: char* 36 | // Ret value: void 37 | bool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp) { 38 | JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); 39 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); 40 | bool ok = true; 41 | std::string arg0; 42 | 43 | ok &= jsval_to_std_string( cx, args.get(0), &arg0 ); 44 | JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); 45 | 46 | localStorageRemoveItem(arg0); 47 | args.rval().setUndefined(); 48 | return true; 49 | } 50 | 51 | // Arguments: char*, char* 52 | // Ret value: void 53 | bool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp) { 54 | JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); 55 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); 56 | bool ok = true; 57 | std::string arg0; std::string arg1; 58 | 59 | ok &= jsval_to_std_string( cx, args.get(0), &arg0 ); 60 | ok &= jsval_to_std_string( cx, args.get(1), &arg1 ); 61 | JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); 62 | 63 | localStorageSetItem(arg0 , arg1); 64 | args.rval().setUndefined(); 65 | return true; 66 | } 67 | 68 | 69 | //#endif // JSB_INCLUDE_SYSTEM 70 | -------------------------------------------------------------------------------- /manual/spine/jsb_cocos2dx_spine_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by ucchen on 2/12/14. 3 | * Copyright (c) 2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __jsb_cocos2dx_spine_manual__ 25 | #define __jsb_cocos2dx_spine_manual__ 26 | 27 | #include "jsapi.h" 28 | #include "spine/spine-cocos2dx.h" 29 | 30 | void register_all_cocos2dx_spine_manual(JSContext* cx, JS::HandleObject global); 31 | 32 | extern jsval speventdata_to_jsval(JSContext* cx, spEventData& v); 33 | extern jsval spevent_to_jsval(JSContext* cx, spEvent& v); 34 | extern jsval spbonedata_to_jsval(JSContext* cx, const spBoneData* v); 35 | extern jsval spbone_to_jsval(JSContext* cx, spBone& v); 36 | extern jsval spskeleton_to_jsval(JSContext* cx, spSkeleton& v); 37 | extern jsval spattachment_to_jsval(JSContext* cx, spAttachment& v); 38 | extern jsval spslotdata_to_jsval(JSContext* cx, spSlotData& v); 39 | extern jsval spslot_to_jsval(JSContext* cx, spSlot& v); 40 | extern jsval sptimeline_to_jsval(JSContext* cx, spTimeline& v); 41 | extern jsval spanimationstate_to_jsval(JSContext* cx, spAnimationState& v); 42 | extern jsval spanimation_to_jsval(JSContext* cx, spAnimation& v); 43 | extern jsval sptrackentry_to_jsval(JSContext* cx, spTrackEntry& v); 44 | 45 | #endif /* defined(__jsb_cocos2dx_spine_manual__) */ 46 | -------------------------------------------------------------------------------- /manual/extension/jsb_cocos2dx_extension_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by James Chen on 3/11/13. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __jsb_cocos2dx_extension_manual__ 25 | #define __jsb_cocos2dx_extension_manual__ 26 | 27 | #include "jsapi.h" 28 | #include "jsfriendapi.h" 29 | #include "mozilla/Maybe.h" 30 | #include "extensions/assets-manager/Downloader.h" 31 | 32 | class __JSDownloaderDelegator : cocos2d::Ref 33 | { 34 | public: 35 | static void download(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleValue callback); 36 | 37 | protected: 38 | __JSDownloaderDelegator(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleValue callback); 39 | ~__JSDownloaderDelegator(); 40 | 41 | private: 42 | void onSuccess(const std::string &srcUrl, const std::string &storagePath, const std::string &customId); 43 | void onError(const cocos2d::extension::Downloader::Error &error); 44 | unsigned char *_buffer; 45 | long _size; 46 | std::shared_ptr _downloader; 47 | std::string _url; 48 | JSContext *_cx; 49 | mozilla::Maybe _jsCallback; 50 | mozilla::Maybe _obj; 51 | }; 52 | 53 | void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject global); 54 | 55 | #endif /* defined(__jsb_cocos2dx_extension_manual__) */ 56 | -------------------------------------------------------------------------------- /script/studio/jsb_studio_boot.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | /** 24 | * @type {Object} Format and manage armature configuration and armature animation 25 | * @name ccs.armatureDataManager 26 | */ 27 | ccs.armatureDataManager = null; 28 | cc.defineGetterSetter(ccs, "armatureDataManager", function() { 29 | return ccs.ArmatureDataManager.getInstance(); 30 | }); 31 | ccs.ArmatureDataManager.prototype.clear = function() { 32 | ccs.ArmatureDataManager.destroyInstance(); 33 | }; 34 | 35 | /** 36 | * @type {Object} Base singleton object for ccs.ActionManager 37 | * @name ccs.actionManager 38 | */ 39 | ccs.actionManager = ccs.ActionManager.getInstance(); 40 | ccs.ActionManager.prototype.clear = function() { 41 | this.releaseActions(); 42 | }; 43 | ccs.ActionManager.prototype.initWithDictionary = function(file, dic, node) { 44 | ccs.actionManager.initWithDictionaryEx(file, JSON.stringify(dic), node); 45 | } 46 | 47 | /** 48 | * The same as cc.Node 49 | * @class 50 | * @extends ccs.Class 51 | */ 52 | ccs.Node = ccs.Node || cc.Node; 53 | ccs.Node.extend = ccs.Node.extend || cc.Node.extend; 54 | 55 | /** 56 | * The same as cc.Sprite 57 | * @class 58 | * @extends ccs.Class 59 | */ 60 | ccs.Sprite = ccs.Sprite || cc.Sprite; 61 | ccs.Sprite.extend = ccs.Sprite.extend || cc.Sprite.extend; 62 | 63 | /** 64 | * The same as cc.Component 65 | * @class 66 | * @extends ccs.Class 67 | */ 68 | ccs.Component = ccs.Component || cc.Component; 69 | ccs.Component.extend = ccs.Component.extend || cc.Component.extend; -------------------------------------------------------------------------------- /manual/localstorage/js_bindings_system_registration.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #include "js_bindings_config.h" 25 | #include "js_bindings_core.h" 26 | #include "local-storage/LocalStorage.h" 27 | #include "cocos2d.h" 28 | 29 | // system 30 | #include "js_bindings_system_functions.h" 31 | 32 | 33 | void jsb_register_system( JSContext *_cx, JS::HandleObject object) 34 | { 35 | // 36 | // sys 37 | // 38 | JS::RootedObject proto(_cx); 39 | JS::RootedObject parent(_cx); 40 | JSObject *sys = JS_NewObject(_cx, nullptr, proto, parent); 41 | JS::RootedValue systemVal(_cx); 42 | systemVal = OBJECT_TO_JSVAL(sys); 43 | JS_SetProperty(_cx, object, "sys", systemVal); 44 | 45 | 46 | // sys.localStorage 47 | JSObject *ls = JS_NewObject(_cx, nullptr, proto, parent); 48 | JS::RootedValue lsVal(_cx); 49 | lsVal = OBJECT_TO_JSVAL(ls); 50 | JS_SetProperty(_cx, JS::RootedObject(_cx, sys), "localStorage", lsVal); 51 | 52 | // sys.localStorage functions 53 | JS::RootedObject system(_cx, ls); 54 | #include "js_bindings_system_functions_registration.h" 55 | 56 | 57 | // Init DB with full path 58 | //NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 59 | //NSString *fullpath = [path stringByAppendingPathComponent:@"jsb.sqlite"]; 60 | std::string strFilePath = cocos2d::FileUtils::getInstance()->getWritablePath(); 61 | strFilePath += "/jsb.sqlite"; 62 | localStorageInit(strFilePath.c_str()); 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /proj.ios_mac/cocos2d_js_bindings.xcodeproj/xcshareddata/xcschemes/libjscocos2d Mac.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 60 | 61 | 63 | 64 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /proj.ios_mac/cocos2d_js_bindings.xcodeproj/xcshareddata/xcschemes/libjscocos2d iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 60 | 61 | 63 | 64 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /script/jsb_spine.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | sp.ANIMATION_EVENT_TYPE = { 24 | START: 0, 25 | END: 1, 26 | COMPLETE: 2, 27 | EVENT: 3 28 | }; 29 | 30 | sp.SkeletonAnimation.prototype._ctor = function(skeletonDataFile, atlasFile, scale) { 31 | if(atlasFile) { 32 | if (isNaN(scale)) { 33 | scale = 1; 34 | } 35 | 36 | this.initWithFile(skeletonDataFile, atlasFile, scale); 37 | this.initialize(); 38 | 39 | this._target = null; 40 | this._callback = null; 41 | } 42 | }; 43 | 44 | sp.SkeletonAnimation.extend = cc.Class.extend; 45 | 46 | // Temporary solution before upgrade the Spine API 47 | sp.SkeletonAnimation.prototype.setAnimationListener = function (target, callback) { 48 | this._target = target; 49 | this._callback = callback; 50 | 51 | this.setStartListener(function (trackIndex) { 52 | if (this._target && this._callback) { 53 | this._callback.call(this._target, this, trackIndex, sp.ANIMATION_EVENT_TYPE.START, null, 0); 54 | } 55 | }); 56 | 57 | this.setEndListener(function (trackIndex) { 58 | if (this._target && this._callback) { 59 | this._callback.call(this._target, this, trackIndex, sp.ANIMATION_EVENT_TYPE.END, null, 0); 60 | } 61 | }); 62 | 63 | this.setCompleteListener(function (trackIndex, loopCount) { 64 | if (this._target && this._callback) { 65 | this._callback.call(this._target, this, trackIndex, sp.ANIMATION_EVENT_TYPE.COMPLETE, null, loopCount); 66 | } 67 | }); 68 | 69 | this.setEventListener(function (trackIndex, event) { 70 | if (this._target && this._callback) { 71 | this._callback.call(this._target, this, trackIndex, sp.ANIMATION_EVENT_TYPE.EVENT, event, 0); 72 | } 73 | }); 74 | } -------------------------------------------------------------------------------- /manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by Huabin LING on 21/1/15. 3 | * Copyright (c) 2015 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #include "jsb_cocos2dx_studio_conversions.h" 25 | #include "cocos2d_specifics.hpp" 26 | #include "cocostudio/CocoStudio.h" 27 | 28 | jsval animationInfo_to_jsval(JSContext* cx, const cocostudio::timeline::AnimationInfo& v) 29 | { 30 | JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); 31 | if (!tmp) return JSVAL_NULL; 32 | bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, std_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && 33 | JS_DefineProperty(cx, tmp, "startIndex", v.startIndex, JSPROP_ENUMERATE | JSPROP_PERMANENT) && 34 | JS_DefineProperty(cx, tmp, "endIndex", v.endIndex, JSPROP_ENUMERATE | JSPROP_PERMANENT); 35 | if (ok) { 36 | return OBJECT_TO_JSVAL(tmp); 37 | } 38 | return JSVAL_NULL; 39 | } 40 | 41 | bool jsval_to_animationInfo(JSContext* cx, JS::HandleValue vp, cocostudio::timeline::AnimationInfo* ret) 42 | { 43 | JS::RootedObject tmp(cx); 44 | JS::RootedValue jsName(cx); 45 | JS::RootedValue jsStartId(cx); 46 | JS::RootedValue jsEndId(cx); 47 | std::string name; 48 | double startIndex, endIndex; 49 | 50 | bool ok = vp.isObject() && 51 | JS_ValueToObject(cx, vp, &tmp) && 52 | JS_GetProperty(cx, tmp, "name", &jsName) && 53 | JS_GetProperty(cx, tmp, "startIndex", &jsStartId) && 54 | JS_GetProperty(cx, tmp, "endIndex", &jsEndId) && 55 | JS::ToNumber(cx, jsStartId, &startIndex) && 56 | JS::ToNumber(cx, jsEndId, &endIndex) && 57 | jsval_to_std_string(cx, jsName, &name) && 58 | !isnan(startIndex) && !isnan(endIndex); 59 | 60 | JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); 61 | 62 | ret->name = name; 63 | ret->startIndex = (int)startIndex; 64 | ret->endIndex = (int)endIndex; 65 | return true; 66 | } 67 | -------------------------------------------------------------------------------- /manual/js_bindings_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __JS_BINDINGS_CORE_H__ 25 | #define __JS_BINDINGS_CORE_H__ 26 | 27 | #include "jsapi.h" 28 | #include "jsfriendapi.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | enum { 35 | JSB_C_FLAG_CALL_FREE = 0, 36 | JSB_C_FLAG_DO_NOT_CALL_FREE =1, 37 | }; 38 | 39 | // structure used by "Object Oriented Functions". 40 | // handle is a pointer to the native object 41 | // flags: flags for the object 42 | struct jsb_c_proxy_s { 43 | unsigned long flags; // Should it be removed at "destructor" time, or not ? 44 | void *handle; // native object, like cpSpace, cpBody, etc. 45 | JS::Heap jsobj; // JS Object. Needed for rooting / unrooting 46 | }; 47 | 48 | // Functions for setting / removing / getting the proxy used by the "C" Object Oriented API. Think of Chipmunk classes 49 | struct jsb_c_proxy_s* jsb_get_c_proxy_for_jsobject( JSObject *jsobj ); 50 | void jsb_del_c_proxy_for_jsobject( JSObject *jsobj ); 51 | void jsb_set_c_proxy_for_jsobject( JSObject *jsobj, void *handle, unsigned long flags); 52 | 53 | // JSObject -> proxy 54 | /** gets a proxy for a given JSObject */ 55 | void* jsb_get_proxy_for_jsobject(JSObject *jsobj); 56 | /** sets a proxy for a given JSObject */ 57 | void jsb_set_proxy_for_jsobject(void* proxy, JSObject *jsobj); 58 | /** dels a proxy for a given JSObject */ 59 | void jsb_del_proxy_for_jsobject(JSObject *jsobj); 60 | 61 | // reverse: proxy -> JSObject 62 | /** gets a JSObject for a given proxy */ 63 | JSObject* jsb_get_jsobject_for_proxy(void *proxy); 64 | /** sets a JSObject for a given proxy */ 65 | void jsb_set_jsobject_for_proxy(JSObject *jsobj, void* proxy); 66 | /** delts a JSObject for a given proxy */ 67 | void jsb_del_jsobject_for_proxy(void* proxy); 68 | 69 | 70 | // needed for callbacks. It does nothing. 71 | bool JSB_do_nothing(JSContext *cx, uint32_t argc, jsval *vp); 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /* __JS_BINDINGS_CORE_H__ */ 78 | -------------------------------------------------------------------------------- /manual/cocosbuilder/js_bindings_ccbreader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by Rohan Kuruvilla on 14/08/2012. 3 | * Copyright (c) 2012 Zynga Inc. 4 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #ifndef __JS_BINDINGS_CCBREADER_H__ 26 | #define __JS_BINDINGS_CCBREADER_H__ 27 | 28 | #include "cocosbuilder_specifics.hpp" 29 | #include "cocosbuilder/CocosBuilder.h" 30 | 31 | class CCBScriptCallbackProxy: public cocos2d::Layer 32 | , public cocosbuilder::CCBSelectorResolver 33 | , public cocosbuilder::CCBMemberVariableAssigner { 34 | 35 | std::string callBackProp; 36 | jsval owner; 37 | 38 | public: 39 | 40 | 41 | CCBScriptCallbackProxy () {} 42 | virtual ~CCBScriptCallbackProxy() {} 43 | 44 | CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBScriptCallbackProxy, create); 45 | virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, 46 | const char * pSelectorName); 47 | 48 | virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Ref * pTarget, 49 | const char * pSelectorName); 50 | virtual bool onAssignCCBMemberVariable(cocos2d::Ref * pTarget, const char * pMemberVariableName, 51 | cocos2d::Node * pNode); 52 | virtual void onNodeLoaded(cocos2d::Node * pNode, 53 | cocosbuilder::NodeLoader * pNodeLoader); 54 | 55 | virtual CCBSelectorResolver * createNew(); 56 | void menuItemCallback(Ref *pSender); 57 | void controlCallback(Ref *pSender, cocos2d::extension::Control::EventType event); 58 | void setCallbackProperty(const char *prop); 59 | void setJSOwner(jsval ownr); 60 | jsval getJSOwner(); 61 | }; 62 | 63 | 64 | class JSLayerLoader : public cocosbuilder::LayerLoader { 65 | public: 66 | CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(JSLayerLoader, loader); 67 | 68 | protected: 69 | CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCBScriptCallbackProxy); 70 | }; 71 | 72 | void register_CCBuilderReader(JSContext *cx, JS::HandleObject global); 73 | bool js_CocosBuilder_Run(JSContext *cx, uint32_t argc, jsval *vp); 74 | 75 | #endif /* __JS_BINDINGS_CCBREADER_H__ */ 76 | 77 | -------------------------------------------------------------------------------- /manual/platform/ios/JavaScriptObjCBridge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | 24 | 25 | #include 26 | #include 27 | #include "jsb_helper.h" 28 | #include "jsapi.h" 29 | #include "jsfriendapi.h" 30 | #include "js_bindings_config.h" 31 | using namespace std; 32 | 33 | #define JSO_ERR_OK (0) 34 | #define JSO_ERR_TYPE_NOT_SUPPORT (-1) 35 | #define JSO_ERR_INVALID_AEGUMENTS (-2) 36 | #define JSO_ERR_METHOD_NOT_FOUND (-3) 37 | #define JSO_ERR_EXCEPTION_OCCURRED (-4) 38 | #define JSO_ERR_CLASS_NOT_FOUND (-5) 39 | #define JSO_ERR_VM_FAILURE (-6) 40 | 41 | class JavaScriptObjCBridge{ 42 | 43 | private: 44 | typedef enum : char 45 | { 46 | TypeInvalid = -1, 47 | TypeVoid = 0, 48 | TypeInteger = 1, 49 | TypeFloat = 2, 50 | TypeBoolean = 3, 51 | TypeString = 4, 52 | TypeVector = 5, 53 | TypeFunction= 6, 54 | } ValueType; 55 | typedef vector ValueTypes; 56 | 57 | typedef union 58 | { 59 | int intValue; 60 | float floatValue; 61 | int boolValue; 62 | string *stringValue; 63 | } ReturnValue; 64 | class CallInfo 65 | { 66 | public: 67 | CallInfo(const char *className, const char *methodName) 68 | :m_valid(false) 69 | ,m_error(JSO_ERR_OK) 70 | ,m_argumentsCount(0) 71 | ,m_methodName(methodName) 72 | ,m_className(className) 73 | ,m_returnType(TypeVoid) 74 | { 75 | } 76 | ~CallInfo(void); 77 | bool isValid(void) { 78 | return m_valid; 79 | } 80 | 81 | int getErrorCode(void) { 82 | return m_error; 83 | } 84 | ValueType getReturnValueType(){ 85 | return m_returnType; 86 | } 87 | ReturnValue getReturnValue(){ 88 | return m_ret; 89 | } 90 | bool execute(JSContext *cx,jsval *argv,unsigned argc); 91 | private: 92 | bool m_valid; 93 | int m_error; 94 | int m_argumentsCount; 95 | string m_className; 96 | string m_methodName; 97 | ValueTypes m_argumentsType; 98 | ValueType m_returnType; 99 | ReturnValue m_ret; 100 | string m_retjstring; 101 | void pushValue(void *val); 102 | }; 103 | JS::Value convertReturnValue(JSContext *cx, ReturnValue retValue, ValueType type); 104 | public: 105 | JS_BINDED_CLASS_GLUE(JSObjCBridge); 106 | JS_BINDED_CONSTRUCTOR(JSObjCBridge); 107 | JS_BINDED_FUNC(JSObjCBridge, callStaticMethod); 108 | }; -------------------------------------------------------------------------------- /manual/spidermonkey_specifics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __SPIDERMONKEY_SPECIFICS_H__ 24 | #define __SPIDERMONKEY_SPECIFICS_H__ 25 | 26 | #include "jsapi.h" 27 | #include "jsfriendapi.h" 28 | #include "uthash.h" 29 | #include 30 | 31 | typedef struct js_proxy { 32 | void *ptr; 33 | JS::Heap obj; 34 | UT_hash_handle hh; 35 | } js_proxy_t; 36 | 37 | extern js_proxy_t *_native_js_global_ht; 38 | extern js_proxy_t *_js_native_global_ht; 39 | 40 | typedef struct js_type_class { 41 | JSClass *jsclass; 42 | JS::Heap proto; 43 | JS::Heap parentProto; 44 | } js_type_class_t; 45 | 46 | extern std::unordered_map _js_global_type_map; 47 | 48 | template< typename DERIVED > 49 | class TypeTest 50 | { 51 | public: 52 | static const char* s_name() 53 | { 54 | // return id unique for DERIVED 55 | // ALWAYS VALID BUT STRING, NOT INT - BUT VALID AND CROSS-PLATFORM/CROSS-VERSION COMPATBLE 56 | // AS FAR AS YOU KEEP THE CLASS NAME 57 | return typeid( DERIVED ).name(); 58 | } 59 | }; 60 | 61 | 62 | #define JS_NEW_PROXY(p, native_obj, js_obj) \ 63 | do { \ 64 | p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \ 65 | assert(p); \ 66 | js_proxy_t* native_obj##js_obj##tmp = NULL; \ 67 | HASH_FIND_PTR(_native_js_global_ht, &native_obj, native_obj##js_obj##tmp); \ 68 | assert(!native_obj##js_obj##tmp); \ 69 | p->ptr = native_obj; \ 70 | p->obj = js_obj; \ 71 | HASH_ADD_PTR(_native_js_global_ht, ptr, p); \ 72 | p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \ 73 | assert(p); \ 74 | native_obj##js_obj##tmp = NULL; \ 75 | HASH_FIND_PTR(_js_native_global_ht, &js_obj, native_obj##js_obj##tmp); \ 76 | assert(!native_obj##js_obj##tmp); \ 77 | p->ptr = native_obj; \ 78 | p->obj = js_obj; \ 79 | HASH_ADD_PTR(_js_native_global_ht, obj, p); \ 80 | } while(0) \ 81 | 82 | #define JS_GET_PROXY(p, native_obj) \ 83 | do { \ 84 | HASH_FIND_PTR(_native_js_global_ht, &native_obj, p); \ 85 | } while (0) 86 | 87 | #define JS_GET_NATIVE_PROXY(p, js_obj) \ 88 | do { \ 89 | HASH_FIND_PTR(_js_native_global_ht, &js_obj, p); \ 90 | } while (0) 91 | 92 | #define JS_REMOVE_PROXY(nproxy, jsproxy) \ 93 | do { \ 94 | if (nproxy) { HASH_DEL(_native_js_global_ht, nproxy); free(nproxy); } \ 95 | if (jsproxy) { HASH_DEL(_js_native_global_ht, jsproxy); free(jsproxy); } \ 96 | } while (0) 97 | 98 | #define TEST_NATIVE_OBJECT(cx, native_obj) \ 99 | if (!native_obj) { \ 100 | JS_ReportError(cx, "Invalid Native Object"); \ 101 | return false; \ 102 | } 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /script/studio/jsb_studio_property_apis.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | var _proto = ccs.Bone.prototype; 24 | cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); 25 | cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); 26 | cc.defineGetterSetter(_proto, "zIndex", _proto.getLocalZOrder, _proto.setLocalZOrder); 27 | cc.defineGetterSetter(_proto, "boneData", _proto.getBoneData, _proto.setBoneData); 28 | cc.defineGetterSetter(_proto, "armature", _proto.getArmature, _proto.setArmature); 29 | cc.defineGetterSetter(_proto, "parentBone", _proto.getParentBone, _proto.setParentBone); 30 | cc.defineGetterSetter(_proto, "childArmature", _proto.getChildArmature, _proto.setChildArmature); 31 | cc.defineGetterSetter(_proto, "childrenBone", _proto.getChildrenBone); 32 | cc.defineGetterSetter(_proto, "tween", _proto.getTween); 33 | cc.defineGetterSetter(_proto, "tweenData", _proto.getTweenData); 34 | cc.defineGetterSetter(_proto, "transformDirty", _proto.getTransformDirty, _proto.setTransformDirty); 35 | cc.defineGetterSetter(_proto, "colliderFilter", _proto.getColliderFilter, _proto.setColliderFilter); 36 | cc.defineGetterSetter(_proto, "displayManager", _proto.getDisplayManager, _proto.setDisplayManager); 37 | cc.defineGetterSetter(_proto, "ignoreMovementBoneData", _proto.getIgnoreMovementBoneData, _proto.setIgnoreMovementBoneData); 38 | cc.defineGetterSetter(_proto, "name", _proto.getName, _proto.setName); 39 | cc.defineGetterSetter(_proto, "blendDirty", _proto.getBlendDirty, _proto.setBlendDirty); 40 | 41 | _proto = ccs.Armature.prototype; 42 | cc.defineGetterSetter(_proto, "parentBone", _proto.getParentBone, _proto.setParentBone); 43 | cc.defineGetterSetter(_proto, "animation", _proto.getAnimation, _proto.setAnimation); 44 | cc.defineGetterSetter(_proto, "armatureData", _proto.getArmatureData, _proto.setArmatureData); 45 | cc.defineGetterSetter(_proto, "name", _proto.getName, _proto.setName); 46 | cc.defineGetterSetter(_proto, "batchNode", _proto.getBatchNode, _proto.setBatchNode); 47 | cc.defineGetterSetter(_proto, "version", _proto.getVersion, _proto.setVersion); 48 | cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody); 49 | cc.defineGetterSetter(_proto, "colliderFilter", _proto.setColliderFilter); 50 | 51 | _proto = ccs.Skin.prototype; 52 | cc.defineGetterSetter(_proto, "skinData", _proto.getSkinData, _proto.setSkinData); 53 | cc.defineGetterSetter(_proto, "bone", _proto.getBone, _proto.setBone); 54 | cc.defineGetterSetter(_proto, "displayName", _proto.getDisplayName); 55 | 56 | _proto = ccs.ColliderDetector.prototype; 57 | cc.defineGetterSetter(_proto, "colliderFilter", _proto.getColliderFilter, _proto.setColliderFilter); 58 | cc.defineGetterSetter(_proto, "active", _proto.getActive, _proto.setActive); 59 | cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody); -------------------------------------------------------------------------------- /script/extension/jsb_ext_create_apis.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | /************************************************************ 24 | * 25 | * Constructors with built in init function 26 | * 27 | ************************************************************/ 28 | 29 | jsb.EventListenerAssetsManager.prototype._ctor = function(assetsManager, callback) { 30 | callback !== undefined && this.init(assetsManager, callback); 31 | }; 32 | 33 | 34 | 35 | cc.ControlButton.prototype._ctor = function(label, backgroundSprite, fontSize){ 36 | if(fontSize != undefined) 37 | this.initWithTitleAndFontNameAndFontSize(label, backgroundSprite, fontSize); 38 | else if(backgroundSprite != undefined) 39 | this.initWithLabelAndBackgroundSprite(label, backgroundSprite); 40 | else if(label != undefined) 41 | this.initWithBackgroundSprite(label); 42 | else 43 | this.init(); 44 | }; 45 | 46 | cc.ControlColourPicker.prototype._ctor = function(){ 47 | this.init(); 48 | }; 49 | 50 | cc.ControlPotentiometer.prototype._ctor = function(backgroundFile, progressFile, thumbFile){ 51 | if (thumbFile != undefined) { 52 | // Prepare track for potentiometer 53 | var backgroundSprite = cc.Sprite.create(backgroundFile); 54 | 55 | // Prepare thumb for potentiometer 56 | var thumbSprite = cc.Sprite.create(thumbFile); 57 | 58 | // Prepare progress for potentiometer 59 | var progressTimer = cc.ProgressTimer.create(cc.Sprite.create(progressFile)); 60 | this.initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite); 61 | } 62 | }; 63 | 64 | cc.ControlSlider.prototype._ctor = function(bgFile, progressFile, thumbFile){ 65 | if (thumbFile != undefined) { 66 | // Prepare background for slider 67 | bgSprite = cc.Sprite.create(bgFile); 68 | 69 | // Prepare progress for slider 70 | progressSprite = cc.Sprite.create(progressFile); 71 | 72 | // Prepare thumb (menuItem) for slider 73 | thumbSprite = cc.Sprite.create(thumbFile); 74 | 75 | this.initWithSprites(bgSprite, progressSprite, thumbSprite); 76 | } 77 | }; 78 | 79 | cc.ControlStepper.prototype._ctor = function(minusSprite, plusSprite){ 80 | plusSprite !== undefined && this.initWithMinusSpriteAndPlusSprite(minusSprite, plusSprite); 81 | }; 82 | 83 | cc.ControlSwitch.prototype._ctor = function(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel){ 84 | offLabel !== undefined && this.initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); 85 | }; 86 | 87 | cc.TableView.prototype._ctor = function(dataSouurce, size, container){ 88 | container == undefined ? this._init(dataSouurce, size) : this._init(dataSouurce, size, container); 89 | }; 90 | 91 | cc.ScrollView.prototype._ctor = function(size, container) { 92 | size == undefined ? this.init() : (container ? this.initWithViewSize(size, container) : this.initWithViewSize(size)); 93 | }; 94 | 95 | 96 | -------------------------------------------------------------------------------- /script/studio/jsb_studio_create_apis.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | /************************ Cocostudio *************************/ 24 | 25 | ccs.Armature.prototype._ctor = function(name, parentBone) { 26 | // parentBone !== undefined && ccs.Armature.prototype.init.call(this, name, parentBone); 27 | if(parentBone !== undefined) 28 | ccs.Armature.prototype.init.call(this, name, parentBone); 29 | else if(name !== undefined) 30 | ccs.Armature.prototype.init.call(this, name); 31 | }; 32 | 33 | ccs.Bone.prototype._ctor = function(name) { 34 | name !== undefined && ccs.Bone.prototype.init.call(this, name); 35 | }; 36 | 37 | ccs.ArmatureAnimation.prototype._ctor = function(armature) { 38 | armature !== undefined && ccs.ArmatureAnimation.prototype.init.call(this, armature); 39 | }; 40 | 41 | ccs.Tween.prototype._ctor = function(bone) { 42 | bone !== undefined && ccs.Tween.prototype.init.call(this, bone); 43 | }; 44 | 45 | ccs.BatchNode.prototype._ctor = function() { 46 | ccs.BatchNode.prototype.init.call(this); 47 | }; 48 | 49 | ccs.DecorativeDisplay.prototype._ctor = function() { 50 | ccs.DecorativeDisplay.prototype.init.call(this); 51 | }; 52 | 53 | ccs.DisplayManager.prototype._ctor = function(bone) { 54 | bone !== undefined && ccs.DisplayManager.prototype.init.call(this, bone); 55 | }; 56 | 57 | ccs.Skin.prototype._ctor = function(fileName, rect) { 58 | if (fileName == null || fileName == "") { 59 | ccs.Skin.prototype.init.call(this); 60 | } else { 61 | if(fileName[0] == "#"){ 62 | ccs.Skin.prototype.initWithSpriteFrameName.call(this, fileName.substr(1)); 63 | } else { 64 | rect ? ccs.Skin.prototype.initWithFile.call(this, fileName) 65 | : ccs.Skin.prototype.initWithFile.call(this, fileName, rect); 66 | } 67 | } 68 | }; 69 | 70 | ccs.ColliderDetector.prototype._ctor = function(bone) { 71 | bone !== undefined && ccs.ColliderDetector.prototype.init.call(this, bone); 72 | }; 73 | 74 | ccs.TriggerObj.prototype._ctor = function() { 75 | ccs.TriggerObj.prototype.init.call(this); 76 | }; 77 | 78 | ccs.ComAttribute.prototype._ctor = function() { 79 | ccs.ComAttribute.prototype.init.call(this); 80 | }; 81 | 82 | ccs.ComAudio.prototype._ctor = function() { 83 | ccs.ComAudio.prototype.init.call(this); 84 | }; 85 | 86 | ccs.ComController.prototype._ctor = function() { 87 | ccs.ComController.prototype.init.call(this); 88 | }; 89 | 90 | ccs.ComRender.prototype._ctor = function() { 91 | ccs.ComRender.prototype.init.call(this); 92 | }; 93 | 94 | ccs.ActionTimelineData.prototype._ctor = function(actionTag) { 95 | if (actionTag !== undefined) 96 | { 97 | ccs.ActionTimelineData.prototype.init.call(this,actionTag); 98 | } 99 | }; 100 | 101 | ccs.ObjectExtensionData.prototype._ctor = function() { 102 | ccs.ObjectExtensionData.prototype.init.call(this); 103 | }; -------------------------------------------------------------------------------- /manual/chipmunk/js_bindings_chipmunk_registration.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | #ifndef JSB_INCLUDE_CHIPMUNK 25 | #define JSB_INCLUDE_CHIPMUNK 26 | #endif 27 | 28 | #include "js_bindings_config.h" 29 | #include "ScriptingCore.h" 30 | 31 | 32 | // chipmunk 33 | #include "js_bindings_chipmunk_auto_classes.h" 34 | #include "js_bindings_chipmunk_functions.h" 35 | #include "js_bindings_chipmunk_manual.h" 36 | 37 | 38 | void jsb_register_chipmunk(JSContext* cx, JS::HandleObject object) 39 | { 40 | // 41 | // Chipmunk 42 | // 43 | JS::RootedObject chipmunk(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); 44 | JS::RootedValue chipmunkVal(cx); 45 | 46 | chipmunkVal = OBJECT_TO_JSVAL(chipmunk); 47 | JS_SetProperty(cx, object, "cp", chipmunkVal); 48 | 49 | JSB_cpBase_createClass(cx, chipmunk, "Base"); // manual base class registration 50 | #include "js_bindings_chipmunk_auto_classes_registration.h" 51 | #include "js_bindings_chipmunk_functions_registration.h" 52 | 53 | // manual 54 | JS_DefineFunction(cx, chipmunk, "spaceAddCollisionHandler", JSB_cpSpaceAddCollisionHandler, 8, JSPROP_PERMANENT | JSPROP_ENUMERATE ); 55 | JS_DefineFunction(cx, chipmunk, "spaceRemoveCollisionHandler", JSB_cpSpaceRemoveCollisionHandler, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); 56 | JS_DefineFunction(cx, chipmunk, "arbiterGetBodies", JSB_cpArbiterGetBodies, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); 57 | JS_DefineFunction(cx, chipmunk, "arbiterGetShapes", JSB_cpArbiterGetShapes, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); 58 | JS_DefineFunction(cx, chipmunk, "bodyGetUserData", JSB_cpBodyGetUserData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); 59 | JS_DefineFunction(cx, chipmunk, "bodySetUserData", JSB_cpBodySetUserData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); 60 | 61 | JS_DefineFunction(cx, chipmunk, "areaForPoly", JSB_cpAreaForPoly, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); 62 | JS_DefineFunction(cx, chipmunk, "momentForPoly", JSB_cpMomentForPoly, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); 63 | JS_DefineFunction(cx, chipmunk, "centroidForPoly", JSB_cpCentroidForPoly, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); 64 | JS_DefineFunction(cx, chipmunk, "recenterPoly", JSB_cpRecenterPoly, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); 65 | 66 | JS::RootedObject space(cx, JSB_cpSpace_object); 67 | JS_DefineFunction(cx, space, "segmentQueryFirst", JSB_cpSpace_segmentQueryFirst, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE); 68 | JS_DefineFunction(cx, space, "nearestPointQueryNearest", JSB_cpSpace_nearestPointQueryNearest, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE); 69 | JS_DefineFunction(cx, space, "eachShape", JSB_cpSpace_eachShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); 70 | JS_DefineFunction(cx, space, "eachBody", JSB_cpSpace_eachBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); 71 | JS_DefineFunction(cx, space, "eachConstraint", JSB_cpSpace_eachConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); 72 | 73 | register_CCPhysicsSprite(cx, object); 74 | register_CCPhysicsDebugNode(cx, object); 75 | } 76 | 77 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #/**************************************************************************** 2 | # Copyright (c) 2014 Chukong Technologies Inc. 3 | # 4 | # http://www.cocos2d-x.org 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to deal 8 | # in the Software without restriction, including without limitation the rights 9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | # copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | # THE SOFTWARE. 23 | # ****************************************************************************/ 24 | 25 | set(cocos_root ../../..) 26 | 27 | #platform 28 | if(WIN32) # Win32 29 | set(PLATFORM_FOLDER win32) 30 | elseif(APPLE)# osx or ios 31 | set(PLATFORM_FOLDER mac) 32 | else() # Assume Linux 33 | set(PLATFORM_FOLDER linux) 34 | endif() 35 | 36 | set(JSBINDING_SRC 37 | auto/jsb_cocos2dx_auto.cpp 38 | auto/jsb_cocos2dx_builder_auto.cpp 39 | auto/jsb_cocos2dx_extension_auto.cpp 40 | auto/jsb_cocos2dx_spine_auto.cpp 41 | auto/jsb_cocos2dx_studio_auto.cpp 42 | auto/jsb_cocos2dx_ui_auto.cpp 43 | auto/jsb_cocos2dx_3d_auto.cpp 44 | auto/jsb_cocos2dx_3d_extension_auto.cpp 45 | manual/ScriptingCore.cpp 46 | manual/cocos2d_specifics.cpp 47 | manual/js_manual_conversions.cpp 48 | manual/js_bindings_core.cpp 49 | manual/js_bindings_opengl.cpp 50 | manual/jsb_opengl_functions.cpp 51 | manual/jsb_opengl_manual.cpp 52 | manual/jsb_opengl_registration.cpp 53 | manual/jsb_event_dispatcher_manual.cpp 54 | manual/chipmunk/js_bindings_chipmunk_manual.cpp 55 | manual/chipmunk/js_bindings_chipmunk_functions.cpp 56 | manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp 57 | manual/chipmunk/js_bindings_chipmunk_registration.cpp 58 | manual/cocosbuilder/js_bindings_ccbreader.cpp 59 | manual/cocostudio/jsb_cocos2dx_studio_manual.cpp 60 | manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp 61 | manual/extension/jsb_cocos2dx_extension_manual.cpp 62 | manual/localstorage/js_bindings_system_functions.cpp 63 | manual/localstorage/js_bindings_system_registration.cpp 64 | manual/network/XMLHTTPRequest.cpp 65 | manual/network/jsb_websocket.cpp 66 | manual/network/jsb_socketio.cpp 67 | manual/spine/jsb_cocos2dx_spine_manual.cpp 68 | manual/ui/jsb_cocos2dx_ui_manual.cpp 69 | manual/3d/jsb_cocos2dx_3d_manual.cpp 70 | ${cocos_root}/cocos/storage/local-storage/LocalStorage.cpp 71 | ) 72 | 73 | include_directories( 74 | auto 75 | manual 76 | manual/cocostudio 77 | manual/spine 78 | ${cocos_root}/external/spidermonkey/include/${PLATFORM_FOLDER} 79 | ${cocos_root}/cocos/base 80 | ${cocos_root}/cocos/2d 81 | ${cocos_root}/cocos/ui 82 | ${cocos_root}/cocos/audio/include 83 | ${cocos_root}/cocos/storage 84 | ${cocos_root}/cocos/network 85 | ${cocos_root}/cocos/platform 86 | ${cocos_root}/extensions 87 | ${cocos_root}/external 88 | ${cocos_root}/cocos/editor-support 89 | ${cocos_root}/cocos/editor-support/spine 90 | ${cocos_root}/cocos/editor-support/cocosbuilder 91 | ${cocos_root}/cocos/editor-support/cocostudio 92 | ${cocos_root}/external/chipmunk/include/chipmunk 93 | ) 94 | 95 | add_library(jscocos2d STATIC 96 | ${JSBINDING_SRC} 97 | ) 98 | 99 | target_link_libraries(jscocos2d 100 | sqlite3 101 | js_static 102 | xxhash 103 | ) 104 | 105 | set_target_properties(jscocos2d 106 | PROPERTIES 107 | ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" 108 | LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" 109 | ) 110 | 111 | -------------------------------------------------------------------------------- /manual/chipmunk/js_bindings_chipmunk_auto_classes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 4 | * Script version: v0.3 5 | */ 6 | #include "js_bindings_config.h" 7 | #ifdef JSB_INCLUDE_CHIPMUNK 8 | 9 | #include "js_bindings_chipmunk_manual.h" 10 | extern JSObject *JSB_cpConstraint_object; 11 | extern JSClass *JSB_cpConstraint_class; 12 | void JSB_cpConstraint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 13 | extern JSObject *JSB_cpGrooveJoint_object; 14 | extern JSClass *JSB_cpGrooveJoint_class; 15 | void JSB_cpGrooveJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 16 | extern JSObject *JSB_cpSimpleMotor_object; 17 | extern JSClass *JSB_cpSimpleMotor_class; 18 | void JSB_cpSimpleMotor_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 19 | extern JSObject *JSB_cpPivotJoint_object; 20 | extern JSClass *JSB_cpPivotJoint_class; 21 | void JSB_cpPivotJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 22 | extern JSObject *JSB_cpPinJoint_object; 23 | extern JSClass *JSB_cpPinJoint_class; 24 | void JSB_cpPinJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 25 | extern JSObject *JSB_cpSlideJoint_object; 26 | extern JSClass *JSB_cpSlideJoint_class; 27 | void JSB_cpSlideJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 28 | extern JSObject *JSB_cpGearJoint_object; 29 | extern JSClass *JSB_cpGearJoint_class; 30 | void JSB_cpGearJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 31 | extern JSObject *JSB_cpDampedRotarySpring_object; 32 | extern JSClass *JSB_cpDampedRotarySpring_class; 33 | void JSB_cpDampedRotarySpring_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 34 | extern JSObject *JSB_cpDampedSpring_object; 35 | extern JSClass *JSB_cpDampedSpring_class; 36 | void JSB_cpDampedSpring_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 37 | extern JSObject *JSB_cpRatchetJoint_object; 38 | extern JSClass *JSB_cpRatchetJoint_class; 39 | void JSB_cpRatchetJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 40 | extern JSObject *JSB_cpRotaryLimitJoint_object; 41 | extern JSClass *JSB_cpRotaryLimitJoint_class; 42 | void JSB_cpRotaryLimitJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 43 | extern JSObject *JSB_cpArbiter_object; 44 | extern JSClass *JSB_cpArbiter_class; 45 | void JSB_cpArbiter_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 46 | extern JSObject *JSB_cpSpace_object; 47 | extern JSClass *JSB_cpSpace_class; 48 | void JSB_cpSpace_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 49 | extern JSObject *JSB_cpBody_object; 50 | extern JSClass *JSB_cpBody_class; 51 | void JSB_cpBody_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 52 | extern JSObject *JSB_cpShape_object; 53 | extern JSClass *JSB_cpShape_class; 54 | void JSB_cpShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 55 | extern JSObject *JSB_cpCircleShape_object; 56 | extern JSClass *JSB_cpCircleShape_class; 57 | void JSB_cpCircleShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 58 | extern JSObject *JSB_cpSegmentShape_object; 59 | extern JSClass *JSB_cpSegmentShape_class; 60 | void JSB_cpSegmentShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 61 | extern JSObject *JSB_cpPolyShape_object; 62 | extern JSClass *JSB_cpPolyShape_class; 63 | void JSB_cpPolyShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 64 | extern JSObject *JSB_cpSegmentQueryInfo_object; 65 | extern JSClass *JSB_cpSegmentQueryInfo_class; 66 | void JSB_cpSegmentQueryInfo_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 67 | extern JSObject *JSB_cpNearestPointQueryInfo_object; 68 | extern JSClass *JSB_cpNearestPointQueryInfo_class; 69 | void JSB_cpNearestPointQueryInfo_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 70 | extern JSObject *JSB_cpSplittingPlane_object; 71 | extern JSClass *JSB_cpSplittingPlane_class; 72 | void JSB_cpSplittingPlane_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); 73 | #endif // JSB_INCLUDE_CHIPMUNK 74 | -------------------------------------------------------------------------------- /proj.android/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := cocos2d_js_android_static 6 | 7 | LOCAL_MODULE_FILENAME := libjscocos2dandroid 8 | 9 | ifeq ($(COCOS_SIMULATOR_BUILD),1) 10 | LOCAL_ARM_MODE := arm 11 | endif 12 | 13 | LOCAL_SRC_FILES := ../manual/platform/android/CCJavascriptJavaBridge.cpp 14 | 15 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../.. \ 16 | $(LOCAL_PATH)/../manual \ 17 | $(LOCAL_PATH)/../manual/platform/android \ 18 | $(LOCAL_PATH)/../../../base \ 19 | $(LOCAL_PATH)/../../../../external/chipmunk/include/chipmunk 20 | 21 | LOCAL_EXPORT_LDLIBS := -lGLESv2 \ 22 | -llog \ 23 | -lz \ 24 | -landroid 25 | 26 | LOCAL_STATIC_LIBRARIES := spidermonkey_static 27 | 28 | include $(BUILD_STATIC_LIBRARY) 29 | 30 | #============================================================== 31 | 32 | include $(CLEAR_VARS) 33 | 34 | LOCAL_MODULE := cocos2d_js_static 35 | 36 | LOCAL_MODULE_FILENAME := libjscocos2d 37 | 38 | LOCAL_SRC_FILES := ../auto/jsb_cocos2dx_3d_auto.cpp \ 39 | ../auto/jsb_cocos2dx_extension_auto.cpp \ 40 | ../auto/jsb_cocos2dx_3d_extension_auto.cpp \ 41 | ../auto/jsb_cocos2dx_spine_auto.cpp \ 42 | ../auto/jsb_cocos2dx_auto.cpp \ 43 | ../auto/jsb_cocos2dx_studio_auto.cpp \ 44 | ../auto/jsb_cocos2dx_builder_auto.cpp \ 45 | ../auto/jsb_cocos2dx_ui_auto.cpp \ 46 | ../manual/ScriptingCore.cpp \ \ 47 | ../manual/cocos2d_specifics.cpp \ 48 | ../manual/js_manual_conversions.cpp \ 49 | ../manual/js_bindings_core.cpp \ 50 | ../manual/js_bindings_opengl.cpp \ 51 | ../manual/jsb_opengl_functions.cpp \ 52 | ../manual/jsb_opengl_manual.cpp \ 53 | ../manual/jsb_opengl_registration.cpp \ 54 | ../manual/jsb_event_dispatcher_manual.cpp \ 55 | ../manual/3d/jsb_cocos2dx_3d_manual.cpp \ 56 | ../manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp \ 57 | ../manual/chipmunk/js_bindings_chipmunk_functions.cpp \ 58 | ../manual/chipmunk/js_bindings_chipmunk_manual.cpp \ 59 | ../manual/chipmunk/js_bindings_chipmunk_registration.cpp \ 60 | ../manual/cocosbuilder/js_bindings_ccbreader.cpp \ 61 | ../manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp \ 62 | ../manual/cocostudio/jsb_cocos2dx_studio_manual.cpp \ 63 | ../manual/extension/jsb_cocos2dx_extension_manual.cpp \ 64 | ../manual/localstorage/js_bindings_system_functions.cpp \ 65 | ../manual/localstorage/js_bindings_system_registration.cpp \ 66 | ../manual/network/jsb_socketio.cpp \ 67 | ../manual/network/jsb_websocket.cpp \ 68 | ../manual/network/XMLHTTPRequest.cpp \ 69 | ../manual/spine/jsb_cocos2dx_spine_manual.cpp \ 70 | ../manual/ui/jsb_cocos2dx_ui_manual.cpp 71 | 72 | 73 | LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT 74 | 75 | LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT 76 | 77 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../manual \ 78 | $(LOCAL_PATH)/../manual/cocostudio \ 79 | $(LOCAL_PATH)/../manual/spine \ 80 | $(LOCAL_PATH)/../auto \ 81 | $(LOCAL_PATH)/../../../2d \ 82 | $(LOCAL_PATH)/../../../base \ 83 | $(LOCAL_PATH)/../../../ui \ 84 | $(LOCAL_PATH)/../../../audio/include \ 85 | $(LOCAL_PATH)/../../../storage \ 86 | $(LOCAL_PATH)/../../../../extensions \ 87 | $(LOCAL_PATH)/../../../editor-support/spine \ 88 | $(LOCAL_PATH)/../../../editor-support/cocosbuilder \ 89 | $(LOCAL_PATH)/../../../editor-support/cocostudio 90 | 91 | 92 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual \ 93 | $(LOCAL_PATH)/../auto \ 94 | $(LOCAL_PATH)/../../../audio/include 95 | 96 | LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_js_android_static 97 | 98 | LOCAL_STATIC_LIBRARIES := cocos2dx_static 99 | LOCAL_STATIC_LIBRARIES += cocos_localstorage_static 100 | 101 | include $(BUILD_STATIC_LIBRARY) 102 | 103 | $(call import-module,.) 104 | $(call import-module,external/spidermonkey/prebuilt/android) 105 | $(call import-module,storage/local-storage) 106 | -------------------------------------------------------------------------------- /manual/platform/android/CCJavascriptJavaBridge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __CC_JAVASCRIPT_JAVA_BRIDGE__ 24 | #define __CC_JAVASCRIPT_JAVA_BRIDGE__ 25 | 26 | #include 27 | #include 28 | #include 29 | #include "jsapi.h" 30 | #include "jsfriendapi.h" 31 | #include "js_bindings_config.h" 32 | #include "jsb_helper.h" 33 | 34 | using namespace std; 35 | 36 | #define JSJ_ERR_OK (0) 37 | #define JSJ_ERR_TYPE_NOT_SUPPORT (-1) 38 | #define JSJ_ERR_INVALID_SIGNATURES (-2) 39 | #define JSJ_ERR_METHOD_NOT_FOUND (-3) 40 | #define JSJ_ERR_EXCEPTION_OCCURRED (-4) 41 | #define JSJ_ERR_VM_THREAD_DETACHED (-5) 42 | #define JSJ_ERR_VM_FAILURE (-6) 43 | 44 | class JavascriptJavaBridge 45 | { 46 | 47 | private: 48 | typedef enum : char 49 | { 50 | TypeInvalid = -1, 51 | TypeVoid = 0, 52 | TypeInteger = 1, 53 | TypeFloat = 2, 54 | TypeBoolean = 3, 55 | TypeString = 4, 56 | TypeVector = 5, 57 | TypeFunction= 6, 58 | } ValueType; 59 | 60 | typedef vector ValueTypes; 61 | 62 | typedef union 63 | { 64 | int intValue; 65 | float floatValue; 66 | int boolValue; 67 | string *stringValue; 68 | } ReturnValue; 69 | 70 | class CallInfo 71 | { 72 | public: 73 | CallInfo(const char *className, const char *methodName, const char *methodSig) 74 | : m_valid(false) 75 | , m_error(JSJ_ERR_OK) 76 | , m_className(className) 77 | , m_methodName(methodName) 78 | , m_methodSig(methodSig) 79 | , m_returnType(TypeVoid) 80 | , m_argumentsCount(0) 81 | , m_retjstring(NULL) 82 | , m_env(NULL) 83 | , m_classID(NULL) 84 | , m_methodID(NULL) 85 | { 86 | memset(&m_ret, 0, sizeof(m_ret)); 87 | m_valid = validateMethodSig() && getMethodInfo(); 88 | } 89 | ~CallInfo(void); 90 | 91 | bool isValid(void) { 92 | return m_valid; 93 | } 94 | 95 | int getErrorCode(void) { 96 | return m_error; 97 | } 98 | 99 | JNIEnv *getEnv(void) { 100 | return m_env; 101 | } 102 | 103 | int argumentTypeAtIndex(size_t index) { 104 | return m_argumentsType.at(index); 105 | } 106 | 107 | int getArgumentsCount(){ 108 | return m_argumentsCount; 109 | } 110 | 111 | ValueType getReturnValueType(){ 112 | return m_returnType; 113 | } 114 | 115 | ReturnValue getReturnValue(){ 116 | return m_ret; 117 | } 118 | 119 | bool execute(void); 120 | bool executeWithArgs(jvalue *args); 121 | 122 | 123 | private: 124 | bool m_valid; 125 | int m_error; 126 | 127 | string m_className; 128 | string m_methodName; 129 | string m_methodSig; 130 | int m_argumentsCount; 131 | ValueTypes m_argumentsType; 132 | ValueType m_returnType; 133 | 134 | ReturnValue m_ret; 135 | jstring m_retjstring; 136 | 137 | JNIEnv *m_env; 138 | jclass m_classID; 139 | jmethodID m_methodID; 140 | 141 | bool validateMethodSig(void); 142 | bool getMethodInfo(void); 143 | ValueType checkType(const string& sig, size_t *pos); 144 | }; 145 | 146 | JS::Value convertReturnValue(JSContext *cx, ReturnValue retValue, ValueType type); 147 | public: 148 | 149 | JS_BINDED_CLASS_GLUE(JavascriptJavaBridge); 150 | JS_BINDED_CONSTRUCTOR(JavascriptJavaBridge); 151 | JS_BINDED_FUNC(JavascriptJavaBridge, callStaticMethod); 152 | 153 | }; 154 | 155 | #endif -------------------------------------------------------------------------------- /auto/jsb_cocos2dx_spine_auto.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __cocos2dx_spine_h__ 2 | #define __cocos2dx_spine_h__ 3 | 4 | #include "jsapi.h" 5 | #include "jsfriendapi.h" 6 | 7 | 8 | extern JSClass *jsb_spine_SkeletonRenderer_class; 9 | extern JSObject *jsb_spine_SkeletonRenderer_prototype; 10 | 11 | bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc, jsval *vp); 12 | void js_cocos2dx_spine_SkeletonRenderer_finalize(JSContext *cx, JSObject *obj); 13 | void js_register_cocos2dx_spine_SkeletonRenderer(JSContext *cx, JS::HandleObject global); 14 | void register_all_cocos2dx_spine(JSContext* cx, JS::HandleObject obj); 15 | bool js_cocos2dx_spine_SkeletonRenderer_setTimeScale(JSContext *cx, uint32_t argc, jsval *vp); 16 | bool js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled(JSContext *cx, uint32_t argc, jsval *vp); 17 | bool js_cocos2dx_spine_SkeletonRenderer_setAttachment(JSContext *cx, uint32_t argc, jsval *vp); 18 | bool js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); 19 | bool js_cocos2dx_spine_SkeletonRenderer_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); 20 | bool js_cocos2dx_spine_SkeletonRenderer_initWithData(JSContext *cx, uint32_t argc, jsval *vp); 21 | bool js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled(JSContext *cx, uint32_t argc, jsval *vp); 22 | bool js_cocos2dx_spine_SkeletonRenderer_setSlotsToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); 23 | bool js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); 24 | bool js_cocos2dx_spine_SkeletonRenderer_setToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); 25 | bool js_cocos2dx_spine_SkeletonRenderer_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); 26 | bool js_cocos2dx_spine_SkeletonRenderer_drawSkeleton(JSContext *cx, uint32_t argc, jsval *vp); 27 | bool js_cocos2dx_spine_SkeletonRenderer_updateWorldTransform(JSContext *cx, uint32_t argc, jsval *vp); 28 | bool js_cocos2dx_spine_SkeletonRenderer_initialize(JSContext *cx, uint32_t argc, jsval *vp); 29 | bool js_cocos2dx_spine_SkeletonRenderer_setDebugBonesEnabled(JSContext *cx, uint32_t argc, jsval *vp); 30 | bool js_cocos2dx_spine_SkeletonRenderer_getDebugBonesEnabled(JSContext *cx, uint32_t argc, jsval *vp); 31 | bool js_cocos2dx_spine_SkeletonRenderer_getTimeScale(JSContext *cx, uint32_t argc, jsval *vp); 32 | bool js_cocos2dx_spine_SkeletonRenderer_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); 33 | bool js_cocos2dx_spine_SkeletonRenderer_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); 34 | bool js_cocos2dx_spine_SkeletonRenderer_setSkin(JSContext *cx, uint32_t argc, jsval *vp); 35 | bool js_cocos2dx_spine_SkeletonRenderer_getSkeleton(JSContext *cx, uint32_t argc, jsval *vp); 36 | bool js_cocos2dx_spine_SkeletonRenderer_createWithFile(JSContext *cx, uint32_t argc, jsval *vp); 37 | bool js_cocos2dx_spine_SkeletonRenderer_SkeletonRenderer(JSContext *cx, uint32_t argc, jsval *vp); 38 | 39 | extern JSClass *jsb_spine_SkeletonAnimation_class; 40 | extern JSObject *jsb_spine_SkeletonAnimation_prototype; 41 | 42 | bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t argc, jsval *vp); 43 | void js_cocos2dx_spine_SkeletonAnimation_finalize(JSContext *cx, JSObject *obj); 44 | void js_register_cocos2dx_spine_SkeletonAnimation(JSContext *cx, JS::HandleObject global); 45 | void register_all_cocos2dx_spine(JSContext* cx, JS::HandleObject obj); 46 | bool js_cocos2dx_spine_SkeletonAnimation_setStartListener(JSContext *cx, uint32_t argc, jsval *vp); 47 | bool js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener(JSContext *cx, uint32_t argc, jsval *vp); 48 | bool js_cocos2dx_spine_SkeletonAnimation_getState(JSContext *cx, uint32_t argc, jsval *vp); 49 | bool js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener(JSContext *cx, uint32_t argc, jsval *vp); 50 | bool js_cocos2dx_spine_SkeletonAnimation_onTrackEntryEvent(JSContext *cx, uint32_t argc, jsval *vp); 51 | bool js_cocos2dx_spine_SkeletonAnimation_setTrackStartListener(JSContext *cx, uint32_t argc, jsval *vp); 52 | bool js_cocos2dx_spine_SkeletonAnimation_update(JSContext *cx, uint32_t argc, jsval *vp); 53 | bool js_cocos2dx_spine_SkeletonAnimation_setCompleteListener(JSContext *cx, uint32_t argc, jsval *vp); 54 | bool js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener(JSContext *cx, uint32_t argc, jsval *vp); 55 | bool js_cocos2dx_spine_SkeletonAnimation_setEventListener(JSContext *cx, uint32_t argc, jsval *vp); 56 | bool js_cocos2dx_spine_SkeletonAnimation_setMix(JSContext *cx, uint32_t argc, jsval *vp); 57 | bool js_cocos2dx_spine_SkeletonAnimation_setEndListener(JSContext *cx, uint32_t argc, jsval *vp); 58 | bool js_cocos2dx_spine_SkeletonAnimation_initialize(JSContext *cx, uint32_t argc, jsval *vp); 59 | bool js_cocos2dx_spine_SkeletonAnimation_clearTracks(JSContext *cx, uint32_t argc, jsval *vp); 60 | bool js_cocos2dx_spine_SkeletonAnimation_clearTrack(JSContext *cx, uint32_t argc, jsval *vp); 61 | bool js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent(JSContext *cx, uint32_t argc, jsval *vp); 62 | bool js_cocos2dx_spine_SkeletonAnimation_createWithFile(JSContext *cx, uint32_t argc, jsval *vp); 63 | bool js_cocos2dx_spine_SkeletonAnimation_SkeletonAnimation(JSContext *cx, uint32_t argc, jsval *vp); 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /script/jsb_cocos2d_constants.js: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-03-10 4 | * Script version: v0.6 5 | */ 6 | 7 | var cc = cc || {}; 8 | cc.Sprite.INDEX_NOT_INITIALIZED = -1; 9 | cc.TMX_ORIENTATION_HEX = 0x1; 10 | cc.TMX_ORIENTATION_ISO = 0x2; 11 | cc.TMX_ORIENTATION_ORTHO = 0x0; 12 | cc.Z_COMPRESSION_BZIP2 = 0x1; 13 | cc.Z_COMPRESSION_GZIP = 0x2; 14 | cc.Z_COMPRESSION_NONE = 0x3; 15 | cc.Z_COMPRESSION_ZLIB = 0x0; 16 | cc.BLEND_DST = 0x303; 17 | cc.BLEND_SRC = 0x1; 18 | cc.DIRECTOR_IOS_USE_BACKGROUND_THREAD = 0x0; 19 | cc.DIRECTOR_MAC_THREAD = 0x0; 20 | cc.DIRECTOR_STATS_INTERVAL = 0.1; 21 | cc.ENABLE_BOX2_D_INTEGRATION = 0x0; 22 | cc.ENABLE_DEPRECATED = 0x1; 23 | cc.ENABLE_GL_STATE_CACHE = 0x1; 24 | cc.ENABLE_PROFILERS = 0x0; 25 | cc.ENABLE_STACKABLE_ACTIONS = 0x1; 26 | cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0x0; 27 | cc.GL_ALL = 0x0; 28 | cc.LABELATLAS_DEBUG_DRAW = 0x0; 29 | cc.LABELBMFONT_DEBUG_DRAW = 0x0; 30 | cc.MAC_USE_DISPLAY_LINK_THREAD = 0x0; 31 | cc.MAC_USE_MAIN_THREAD = 0x2; 32 | cc.MAC_USE_OWN_THREAD = 0x1; 33 | cc.NODE_RENDER_SUBPIXEL = 0x1; 34 | cc.PVRMIPMAP_MAX = 0x10; 35 | cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 0x1; 36 | cc.SPRITE_DEBUG_DRAW = 0x0; 37 | cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0x0; 38 | cc.TEXTURE_ATLAS_USE_VAO = 0x1; 39 | cc.USE_L_A88_LABELS = 0x1; 40 | cc.ACTION_TAG_INVALID = -1; 41 | cc.DEVICE_MAC = 0x6; 42 | cc.DEVICE_MAC_RETINA_DISPLAY = 0x7; 43 | cc.DEVICEI_PAD = 0x4; 44 | cc.DEVICEI_PAD_RETINA_DISPLAY = 0x5; 45 | cc.DEVICEI_PHONE = 0x0; 46 | cc.DEVICEI_PHONE5 = 0x2; 47 | cc.DEVICEI_PHONE5_RETINA_DISPLAY = 0x3; 48 | cc.DEVICEI_PHONE_RETINA_DISPLAY = 0x1; 49 | cc.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1; 50 | cc.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0; 51 | cc.FLIPED_ALL = 0xe0000000; 52 | cc.FLIPPED_MASK = 0x1fffffff; 53 | cc.IMAGE_FORMAT_JPEG = 0x0; 54 | cc.IMAGE_FORMAT_PNG = 0x1; 55 | cc.ITEM_SIZE = 0x20; 56 | cc.LABEL_AUTOMATIC_WIDTH = -1; 57 | cc.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1; 58 | cc.LINE_BREAK_MODE_CLIP = 0x2; 59 | cc.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3; 60 | cc.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5; 61 | cc.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4; 62 | cc.LINE_BREAK_MODE_WORD_WRAP = 0x0; 63 | cc.MAC_VERSION_10_6 = 0xa060000; 64 | cc.MAC_VERSION_10_7 = 0xa070000; 65 | cc.MAC_VERSION_10_8 = 0xa080000; 66 | cc.MENU_HANDLER_PRIORITY = -128; 67 | cc.MENU_STATE_TRACKING_TOUCH = 0x1; 68 | cc.MENU_STATE_WAITING = 0x0; 69 | cc.NODE_TAG_INVALID = -1; 70 | 71 | cc.ParticleSystem.TYPE_FREE = 0; 72 | cc.ParticleSystem.TYPE_RELATIVE = 1; 73 | cc.ParticleSystem.TYPE_GROUPED = 2; 74 | cc.ParticleSystem.DURATION_INFINITY = -1; 75 | cc.ParticleSystem.MODE_GRAVITY = 0; 76 | cc.ParticleSystem.MODE_RADIUS = 1; 77 | cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE = -1; 78 | cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS = -1; 79 | 80 | cc.PRIORITY_NON_SYSTEM_MIN = -2147483647; 81 | cc.ProgressTimer.TYPE_BAR = 0x1; 82 | cc.ProgressTimer.TYPE_RADIAL = 0x0; 83 | cc.RESOLUTION_MAC = 0x1; 84 | cc.RESOLUTION_MAC_RETINA_DISPLAY = 0x2; 85 | cc.RESOLUTION_UNKNOWN = 0x0; 86 | cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000; 87 | cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000; 88 | cc.TMX_TILE_VERTICAL_FLAG = 0x40000000; 89 | 90 | cc.TEXT_ALIGNMENT_CENTER = 1; 91 | cc.TEXT_ALIGNMENT_RIGHT = 2; 92 | cc.TEXT_ALIGNMENT_LEFT = 0; 93 | 94 | cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0; 95 | cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1; 96 | cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2; 97 | 98 | cc.TOUCHES_ALL_AT_ONCE = 0x0; 99 | cc.TOUCHES_ONE_BY_ONE = 0x1; 100 | cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1; 101 | cc.TRANSITION_ORIENTATION_LEFT_OVER = 0x0; 102 | cc.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1; 103 | cc.TRANSITION_ORIENTATION_UP_OVER = 0x0; 104 | cc.UNIFORM_COS_TIME = 0x5; 105 | cc.UNIFORM_MV_MATRIX = 0x1; 106 | cc.UNIFORM_MVP_MATRIX = 0x2; 107 | cc.UNIFORM_P_MATRIX = 0x0; 108 | cc.UNIFORM_RANDOM01 = 0x6; 109 | cc.UNIFORM_SAMPLER = 0x7; 110 | cc.UNIFORM_SIN_TIME = 0x4; 111 | cc.UNIFORM_TIME = 0x3; 112 | cc.UNIFORM_MAX = 0x8; 113 | cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2; 114 | cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1; 115 | cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0; 116 | cc.OS_VERSION_4_0 = 0x4000000; 117 | cc.OS_VERSION_4_0_1 = 0x4000100; 118 | cc.OS_VERSION_4_1 = 0x4010000; 119 | cc.OS_VERSION_4_2 = 0x4020000; 120 | cc.OS_VERSION_4_2_1 = 0x4020100; 121 | cc.OS_VERSION_4_3 = 0x4030000; 122 | cc.OS_VERSION_4_3_1 = 0x4030100; 123 | cc.OS_VERSION_4_3_2 = 0x4030200; 124 | cc.OS_VERSION_4_3_3 = 0x4030300; 125 | cc.OS_VERSION_4_3_4 = 0x4030400; 126 | cc.OS_VERSION_4_3_5 = 0x4030500; 127 | cc.OS_VERSION_5_0 = 0x5000000; 128 | cc.OS_VERSION_5_0_1 = 0x5000100; 129 | cc.OS_VERSION_5_1_0 = 0x5010000; 130 | cc.OS_VERSION_6_0_0 = 0x6000000; 131 | cc.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification'; 132 | cc.CHIPMUNK_IMPORT = 'chipmunk.h'; 133 | cc.ATTRIBUTE_NAME_COLOR = 'a_color'; 134 | cc.ATTRIBUTE_NAME_POSITION = 'a_position'; 135 | cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord'; 136 | cc.ATTRIBUTE_NAME_TEX_COORD1 = "a_texCoord1"; 137 | cc.ATTRIBUTE_NAME_TEX_COORD2 = "a_texCoord2"; 138 | cc.ATTRIBUTE_NAME_TEX_COORD3 = "a_texCoord3"; 139 | cc.ATTRIBUTE_NAME_NORMAL = "a_normal"; 140 | cc.ATTRIBUTE_NAME_BLEND_WEIGHT = "a_blendWeight"; 141 | cc.ATTRIBUTE_NAME_BLEND_INDEX = "a_blendIndex"; 142 | -------------------------------------------------------------------------------- /script/jsb.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | // 24 | // Javascript Bindigns helper file 25 | // 26 | 27 | // DO NOT ALTER THE ORDER 28 | require('script/jsb_cocos2d_constants.js'); 29 | require('script/jsb_cocos2d.js'); 30 | require('script/jsb_common.js'); 31 | require('script/jsb_property_impls.js'); 32 | require('script/jsb_property_apis.js'); 33 | require('script/jsb_create_apis.js'); 34 | 35 | if (cc.GLNode) { 36 | cc.GLNode.extend = cc.Class.extend; // move from jsb_cocos2d_extension 37 | } 38 | 39 | if (window.ccs) { 40 | require('script/studio/jsb_studio_boot.js'); 41 | ccs.Armature.extend = cc.Class.extend; // move from jsb_cocos2d.js 42 | require('script/studio/jsb_cocos2d_studio.js'); 43 | require('script/studio/jsb_studio_property_apis.js'); 44 | require('script/studio/jsb_studio_create_apis.js'); 45 | 46 | require('script/studio/jsb_studio_load.js'); 47 | require('script/studio/parsers/action-1.x.js'); 48 | require('script/studio/parsers/action-2.x.js'); 49 | require('script/studio/parsers/scene-1.x.js'); 50 | require('script/studio/parsers/timelineParser-1.x.js'); 51 | require('script/studio/parsers/timelineParser-2.x.js'); 52 | require('script/studio/parsers/uiParser-1.x.js'); 53 | require('script/studio/parsers/compatible.js'); 54 | } 55 | 56 | if (window.ccui) { 57 | // move from jsb_boot.js line 912 58 | //start------------------------------ 59 | cc.EditBox = ccui.EditBox; 60 | delete ccui.EditBox; 61 | 62 | cc.Scale9Sprite = ccui.Scale9Sprite; 63 | 64 | // GUI 65 | /** 66 | * @type {Object} 67 | * UI Helper 68 | */ 69 | ccui.helper = ccui.Helper; 70 | //end------------------------------ 71 | 72 | // move from jsb_cocos2d 73 | //start------------------------------ 74 | ccui.Widget.extend = cc.Class.extend; 75 | ccui.Button.extend = cc.Class.extend; 76 | ccui.CheckBox.extend = cc.Class.extend; 77 | ccui.ImageView.extend = cc.Class.extend; 78 | ccui.LoadingBar.extend = cc.Class.extend; 79 | ccui.RichText.extend = cc.Class.extend; 80 | ccui.Slider.extend = cc.Class.extend; 81 | ccui.Text.extend = cc.Class.extend; 82 | ccui.TextAtlas.extend = cc.Class.extend; 83 | ccui.TextBMFont.extend = cc.Class.extend; 84 | ccui.TextField.extend = cc.Class.extend; 85 | ccui.Layout.extend = cc.Class.extend; 86 | ccui.ListView.extend = cc.Class.extend; 87 | ccui.PageView.extend = cc.Class.extend; 88 | ccui.ScrollView.extend = cc.Class.extend; 89 | ccui.Scale9Sprite.extend = cc.Class.extend; 90 | //end------------------------------ 91 | 92 | require('script/ccui/jsb_cocos2d_ui.js'); 93 | require('script/ccui/jsb_ccui_property_impls.js'); 94 | require('script/ccui/jsb_ccui_property_apis.js'); 95 | require('script/ccui/jsb_ccui_create_apis.js'); 96 | require('script/ccui/jsb_ccui_deprecated.js'); 97 | } 98 | 99 | if (cc.ControlButton) { 100 | require('script/extension/jsb_cocos2d_extension.js'); 101 | require('script/extension/jsb_ext_property_apis.js'); 102 | require('script/extension/jsb_ext_create_apis.js'); 103 | } 104 | 105 | if (cc.PhysicsSprite) { 106 | cc.PhysicsSprite.extend = cc.Class.extend;// move from jsb_cocos2d.js 107 | require('script/physicsSprite/jsb_physicsSprite.js'); 108 | } 109 | 110 | if (window.cp) { 111 | // chipmunk 112 | require('script/chipmunk/jsb_chipmunk_constants.js'); 113 | require('script/chipmunk/jsb_chipmunk.js'); 114 | } 115 | 116 | require('script/jsb_opengl_constants.js'); 117 | require('script/jsb_opengl.js'); 118 | require('script/jsb_cocosbuilder.js'); 119 | require('script/jsb_deprecated.js'); 120 | require('script/jsb_loaders.js'); 121 | require('script/jsb_pool.js'); 122 | 123 | if (jsb.fileUtils.isFileExist('jsb_pluginx.js')) { 124 | if (cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_ANDROID) { 125 | require('jsb_pluginx.js'); 126 | } 127 | } 128 | 129 | if (window.sp) { 130 | require('script/jsb_spine.js'); 131 | } 132 | 133 | if (jsb.Sprite3D){ 134 | require('script/3d/jsb_cocos2d_3d.js'); 135 | } 136 | 137 | if (jsb.ParticleSystem3D) { 138 | require('script/3d/jsb_cocos2d_3d_ext.js'); 139 | } -------------------------------------------------------------------------------- /script/jsb_deprecated.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | // Deprecated functions 24 | 25 | var cc = cc || {}; 26 | 27 | (function() { 28 | 29 | var logW = function(old_name, new_name) { 30 | cc.log("\n********** \n"+old_name +" was deprecated, please use "+ new_name +" instead.\n**********"); 31 | }; 32 | 33 | // Deprecated static functions 34 | cc.AnimationCache.purgeSharedAnimationCache = function() { 35 | logW("cc.AnimationCache.purgeSharedAnimationCache", "cc.AnimationCache.destroyInstance"); 36 | cc.AnimationCache.destroyInstance(); 37 | }; 38 | 39 | cc.TextureCache.getInstance = function() { 40 | return cc.Director.getInstance().getTextureCache(); 41 | }; 42 | 43 | // Deprecated member functions 44 | cc.Action.prototype.copy = function() { 45 | logW("cc.Action.copy", "cc.Action.clone"); 46 | return cc.Action.prototype.clone.apply(this, arguments); 47 | }; 48 | 49 | cc.Animation.prototype.copy = function() { 50 | logW("cc.Animation.copy", "cc.Animation.clone"); 51 | return cc.Animation.prototype.clone.apply(this, arguments); 52 | }; 53 | 54 | cc.Node.prototype.nodeToWorldTransform = function() { 55 | logW("cc.Node.nodeToWorldTransform", "cc.Node.getNodeToWorldTransform"); 56 | return cc.Node.prototype.getNodeToWorldTransform.apply(this, arguments); 57 | }; 58 | 59 | cc.Node.prototype.getZOrder = function() { 60 | logW("cc.Node.getZOrder", "cc.Node.getLocalZOrder"); 61 | return cc.Node.prototype.getLocalZOrder.apply(this, arguments); 62 | }; 63 | 64 | cc.Node.prototype.setZOrder = function() { 65 | logW("cc.Node.setZOrder", "cc.Node.setLocalZOrder"); 66 | cc.Node.prototype.setLocalZOrder.apply(this, arguments); 67 | }; 68 | 69 | cc.Node.prototype.nodeToParentTransform = function() { 70 | logW("cc.Node.nodeToParentTransform", "cc.Node.getNodeToParentTransform"); 71 | return cc.Node.prototype.getNodeToParentTransform.apply(this, arguments); 72 | }; 73 | 74 | cc.Node.prototype.worldToNodeTransform = function() { 75 | logW("cc.Node.worldToNodeTransform", "cc.Node.getWorldToNodeTransform"); 76 | return cc.Node.prototype.getWorldToNodeTransform.apply(this, arguments); 77 | }; 78 | 79 | cc.Node.prototype.parentToNodeTransform = function() { 80 | logW("cc.Node.parentToNodeTransform", "cc.Node.getParentToNodeTransform"); 81 | return cc.Node.prototype.getParentToNodeTransform.apply(this, arguments); 82 | }; 83 | 84 | cc.Node.prototype.numberOfRunningActions = function() { 85 | logW("cc.Node.numberOfRunningActions", "cc.Node.getNumberOfRunningActions"); 86 | return cc.Node.prototype.getNumberOfRunningActions.apply(this, arguments); 87 | }; 88 | 89 | cc.Node.prototype.numberOfRunningActionsInTarget = function() { 90 | logW("cc.Node.numberOfRunningActionsInTarget", "cc.Node.getNumberOfRunningActionsInTarget"); 91 | return cc.Node.prototype.getNumberOfRunningActionsInTarget.apply(this, arguments); 92 | }; 93 | 94 | cc.Menu.prototype.setHandlerPriority = function() { 95 | cc.log("cc.Menu.setHandlerPriority was deprecated, 3.0 uses new event dispatcher to dispatch touch event based on draw order, so setHandlerPriority is not needed now."); 96 | }; 97 | 98 | cc.Layer.prototype.setKeypadEnabled = function() { 99 | logW("cc.Layer.setKeypadEnabled", "cc.Layer.setKeyboardEnabled"); 100 | return cc.Layer.prototype.setKeyboardEnabled.apply(this, arguments); 101 | }; 102 | 103 | cc.Layer.prototype.isKeypadEnabled = function() { 104 | logW("cc.Layer.isKeypadEnabled", "cc.Layer.isKeyboardEnabled"); 105 | return cc.Layer.prototype.isKeyboardEnabled.apply(this, arguments); 106 | }; 107 | 108 | cc.registerTargettedDelegate = function() { 109 | logW("cc.registerTargettedDelegate", "cc.registerTargetedDelegate"); 110 | return cc.registerTargetedDelegate.apply(this, arguments); 111 | }; 112 | 113 | cc.Touch.prototype.getId = function(){ 114 | logW("cc.Touch.getId", "cc.Touch.getID"); 115 | return this.getID(); 116 | }; 117 | 118 | })(); 119 | -------------------------------------------------------------------------------- /manual/js_bindings_core.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | #include "js_bindings_config.h" 24 | #include "js_bindings_core.h" 25 | 26 | // cocos2d + chipmunk registration files 27 | #include "chipmunk/js_bindings_chipmunk_registration.h" 28 | #include "cocos2d.h" 29 | 30 | //#pragma mark - Hash 31 | 32 | typedef struct _hashJSObject 33 | { 34 | JSObject *jsObject; 35 | void *proxy; 36 | UT_hash_handle hh; 37 | } tHashJSObject; 38 | 39 | static tHashJSObject *hash = NULL; 40 | static tHashJSObject *reverse_hash = NULL; 41 | 42 | //#pragma mark JSBCore - Helper free functions 43 | static void reportError(JSContext *cx, const char *message, JSErrorReport *report) 44 | { 45 | fprintf(stderr, "%s:%u:%s\n", 46 | report->filename ? report->filename : "", 47 | (unsigned int) report->lineno, 48 | message); 49 | }; 50 | 51 | 52 | // Hash of JSObject -> proxy 53 | void* jsb_get_proxy_for_jsobject(JSObject *obj) 54 | { 55 | tHashJSObject *element = NULL; 56 | HASH_FIND_PTR(hash, &obj, element); 57 | 58 | if( element ) 59 | return element->proxy; 60 | return NULL; 61 | } 62 | 63 | void jsb_set_proxy_for_jsobject(void *proxy, JSObject *obj) 64 | { 65 | CCASSERT( !jsb_get_proxy_for_jsobject(obj), "Already added. abort"); 66 | 67 | // printf("Setting proxy for: %p - %p (%s)\n", obj, proxy, [[proxy description] UTF8String] ); 68 | 69 | tHashJSObject *element = (tHashJSObject*) malloc( sizeof( *element ) ); 70 | 71 | // XXX: Do not retain it here. 72 | // [proxy retain]; 73 | element->proxy = proxy; 74 | element->jsObject = obj; 75 | 76 | HASH_ADD_PTR( hash, jsObject, element ); 77 | } 78 | 79 | void jsb_del_proxy_for_jsobject(JSObject *obj) 80 | { 81 | tHashJSObject *element = NULL; 82 | HASH_FIND_PTR(hash, &obj, element); 83 | if( element ) { 84 | HASH_DEL(hash, element); 85 | free(element); 86 | } 87 | } 88 | 89 | //#pragma mark Proxy -> JSObject 90 | 91 | // Reverse hash: Proxy -> JSObject 92 | JSObject* jsb_get_jsobject_for_proxy(void *proxy) 93 | { 94 | tHashJSObject *element = NULL; 95 | HASH_FIND_PTR(reverse_hash, &proxy, element); 96 | 97 | if( element ) 98 | return element->jsObject; 99 | return NULL; 100 | } 101 | 102 | void jsb_set_jsobject_for_proxy(JSObject *jsobj, void* proxy) 103 | { 104 | CCASSERT( !jsb_get_jsobject_for_proxy(proxy), "Already added. abort"); 105 | 106 | tHashJSObject *element = (tHashJSObject*) malloc( sizeof( *element ) ); 107 | 108 | element->proxy = proxy; 109 | element->jsObject = jsobj; 110 | 111 | HASH_ADD_PTR( reverse_hash, proxy, element ); 112 | } 113 | 114 | void jsb_del_jsobject_for_proxy(void* proxy) 115 | { 116 | tHashJSObject *element = NULL; 117 | HASH_FIND_PTR(reverse_hash, &proxy, element); 118 | if( element ) { 119 | HASH_DEL(reverse_hash, element); 120 | free(element); 121 | } 122 | } 123 | 124 | //#pragma mark 125 | 126 | 127 | //#pragma mark "C" proxy functions 128 | 129 | struct jsb_c_proxy_s* jsb_get_c_proxy_for_jsobject( JSObject *jsobj ) 130 | { 131 | struct jsb_c_proxy_s *proxy = (struct jsb_c_proxy_s *) JS_GetPrivate(jsobj); 132 | 133 | return proxy; 134 | } 135 | 136 | void jsb_del_c_proxy_for_jsobject( JSObject *jsobj ) 137 | { 138 | struct jsb_c_proxy_s *proxy = (struct jsb_c_proxy_s *) JS_GetPrivate(jsobj); 139 | CCASSERT(proxy, "Invalid proxy for JSObject"); 140 | JS_SetPrivate(jsobj, NULL); 141 | 142 | free(proxy); 143 | } 144 | 145 | void jsb_set_c_proxy_for_jsobject( JSObject *jsobj, void *handle, unsigned long flags) 146 | { 147 | struct jsb_c_proxy_s *proxy = (struct jsb_c_proxy_s*) malloc(sizeof(*proxy)); 148 | CCASSERT(proxy, "No memory for proxy"); 149 | 150 | proxy->handle = handle; 151 | proxy->flags = flags; 152 | proxy->jsobj = jsobj; 153 | 154 | JS_SetPrivate(jsobj, proxy); 155 | } 156 | 157 | 158 | //#pragma mark Do Nothing - Callbacks 159 | 160 | bool JSB_do_nothing(JSContext *cx, uint32_t argc, jsval *vp) 161 | { 162 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); 163 | args.rval().setUndefined(); 164 | return true; 165 | } 166 | -------------------------------------------------------------------------------- /script/ccui/jsb_ccui_property_impls.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | // Override width and height getter setter 24 | _forceExtend(ccui.Widget.prototype, { 25 | _getXPercent: function() { 26 | return this.getPositionPercent().x; 27 | }, 28 | _getYPercent: function() { 29 | return this.getPositionPercent().y; 30 | }, 31 | 32 | _setXPercent: function(x) { 33 | var p = cc.p(x, this.getPositionPercent().y); 34 | this.setPositionPercent(p); 35 | }, 36 | _setYPercent: function(y) { 37 | var p = cc.p(this.getPositionPercent().x, y); 38 | this.setPositionPercent(p); 39 | }, 40 | 41 | _getWidth: function() { 42 | return this.getContentSize().width; 43 | }, 44 | _getHeight: function() { 45 | return this.getContentSize().height; 46 | }, 47 | _getWidthPercent: function() { 48 | return this.getSizePercent().width; 49 | }, 50 | _getHeightPercent: function() { 51 | return this.getSizePercent().height; 52 | }, 53 | 54 | _setWidth: function(w) { 55 | var size = cc.size(w, this.getContentSize().height); 56 | this.setContentSize(size); 57 | }, 58 | _setHeight: function(h) { 59 | var size = cc.size(this.getContentSize().width, h); 60 | this.setContentSize(size); 61 | }, 62 | _setWidthPercent: function(w) { 63 | var size = cc.size(w, this.getSizePercent().height); 64 | this.setSizePercent(size); 65 | }, 66 | _setHeightPercent: function(h) { 67 | var size = cc.size(this.getSizePercent().width, h); 68 | this.setSizePercent(size); 69 | } 70 | }); 71 | 72 | _safeExtend(ccui.Button.prototype, { 73 | _fontStyleRE: /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/, 74 | 75 | _getTitleFont: function() { 76 | var size = this.getTitleFontSize(); 77 | var name = this.getTitleFontName(); 78 | return size + "px '" + name + "'"; 79 | }, 80 | 81 | _setTitleFont: function(fontStyle) { 82 | var res = this._fontStyleRE.exec(fontStyle); 83 | if(res) { 84 | this.setTitleFontSize(parseInt(res[1])); 85 | this.setTitleFontName(res[2]); 86 | } 87 | } 88 | }); 89 | 90 | _safeExtend(ccui.Text.prototype, { 91 | _getBoundingWidth: function() { 92 | return this.getTextAreaSize().width; 93 | }, 94 | _getBoundingHeight: function() { 95 | return this.getTextAreaSize().height; 96 | }, 97 | 98 | _setBoundingWidth: function(w) { 99 | var size = cc.size(w, this.getTextAreaSize().height); 100 | this.setTextAreaSize(size); 101 | }, 102 | _setBoundingHeight: function(h) { 103 | var size = cc.size(this.getTextAreaSize().width, h); 104 | this.setTextAreaSize(size); 105 | } 106 | }); 107 | 108 | _safeExtend(ccui.TextField.prototype, { 109 | _fontStyleRE: /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/, 110 | 111 | _getFont: function() { 112 | var size = this.getFontSize(); 113 | var name = this.getFontName(); 114 | return size + "px '" + name + "'"; 115 | }, 116 | 117 | _setFont: function(fontStyle) { 118 | var res = this._fontStyleRE.exec(fontStyle); 119 | if(res) { 120 | this.setFontSize(parseInt(res[1])); 121 | this.setFontName(res[2]); 122 | } 123 | } 124 | }); 125 | 126 | _safeExtend(ccui.ScrollView.prototype, { 127 | _getInnerWidth: function() { 128 | return this.getInnerContainerSize().width; 129 | }, 130 | _getInnerHeight: function() { 131 | return this.getInnerContainerSize().height; 132 | }, 133 | 134 | _setInnerWidth: function(w) { 135 | var size = cc.size(w, this.getInnerContainerSize().height); 136 | this.setInnerContainerSize(size); 137 | }, 138 | _setInnerHeight: function(h) { 139 | var size = cc.size(this.getInnerContainerSize().width, h); 140 | this.setInnerContainerSize(size); 141 | } 142 | }); 143 | 144 | // _safeExtend(ccui.EditBox.prototype, { 145 | // _setFont: function(fontStyle) { 146 | // var res = cc.LabelTTF.prototype._fontStyleRE.exec(fontStyle); 147 | // if(res) { 148 | // this.setFontSize(parseInt(res[1])); 149 | // this.setFontName(res[2]); 150 | // } 151 | // } 152 | // }); -------------------------------------------------------------------------------- /manual/jsb_helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __XMLHTTPHELPER_H__ 24 | #define __XMLHTTPHELPER_H__ 25 | 26 | #include "jsapi.h" 27 | #include "jsfriendapi.h" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | //#pragma mark - Helpful Macros 34 | 35 | #define JS_BINDED_CLASS_GLUE(klass) \ 36 | static JSClass js_class; \ 37 | static JSObject* js_proto; \ 38 | static JSObject* js_parent; \ 39 | static void _js_register(JSContext* cx, JS::HandleObject global); 40 | 41 | #define JS_BINDED_CLASS_GLUE_IMPL(klass) \ 42 | JSClass klass::js_class = {}; \ 43 | JSObject* klass::js_proto = NULL; \ 44 | JSObject* klass::js_parent = NULL; \ 45 | 46 | #define JS_BINDED_FUNC(klass, name) \ 47 | bool name(JSContext *cx, unsigned argc, jsval *vp) 48 | 49 | #define JS_BINDED_CONSTRUCTOR(klass) \ 50 | static bool _js_constructor(JSContext *cx, unsigned argc, jsval *vp) 51 | 52 | #define JS_BINDED_CONSTRUCTOR_IMPL(klass) \ 53 | bool klass::_js_constructor(JSContext *cx, unsigned argc, jsval *vp) 54 | 55 | #define JS_BINDED_FUNC_IMPL(klass, name) \ 56 | static bool klass##_func_##name(JSContext *cx, unsigned argc, jsval *vp) { \ 57 | JSObject* thisObj = JS_THIS_OBJECT(cx, vp); \ 58 | klass* obj = (klass*)JS_GetPrivate(thisObj); \ 59 | if (obj) { \ 60 | return obj->name(cx, argc, vp); \ 61 | } \ 62 | JS_ReportError(cx, "Invalid object call for function %s", #name); \ 63 | return false; \ 64 | } \ 65 | bool klass::name(JSContext *cx, unsigned argc, jsval *vp) 66 | 67 | #define JS_WRAP_OBJECT_IN_VAL(klass, cobj, out) \ 68 | do { \ 69 | JSObject *obj = JS_NewObject(cx, &klass::js_class, klass::js_proto, klass::js_parent); \ 70 | if (obj) { \ 71 | JS_SetPrivate(obj, cobj); \ 72 | out = OBJECT_TO_JSVAL(obj); \ 73 | } \ 74 | } while(0) \ 75 | 76 | #define JS_BINDED_FUNC_FOR_DEF(klass, name) \ 77 | JS_FN(#name, klass##_func_##name, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT) 78 | 79 | #define JS_BINDED_PROP_GET(klass, propName) \ 80 | bool _js_get_##propName(JSContext *cx, const JS::CallArgs& args) 81 | 82 | #define JS_BINDED_PROP_GET_IMPL(klass, propName) \ 83 | static bool _js_get_##klass##_##propName(JSContext *cx, unsigned argc, jsval *vp) { \ 84 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \ 85 | JSObject* obj = args.thisv().toObjectOrNull(); \ 86 | klass* cobj = (klass*)JS_GetPrivate(obj); \ 87 | if (cobj) { \ 88 | return cobj->_js_get_##propName(cx, args); \ 89 | } \ 90 | JS_ReportError(cx, "Invalid getter call for property %s", #propName); \ 91 | return false; \ 92 | } \ 93 | bool klass::_js_get_##propName(JSContext *cx, const JS::CallArgs& args) 94 | 95 | #define JS_BINDED_PROP_SET(klass, propName) \ 96 | bool _js_set_##propName(JSContext *cx, const JS::CallArgs& args) 97 | 98 | #define JS_BINDED_PROP_SET_IMPL(klass, propName) \ 99 | static bool _js_set_##klass##_##propName(JSContext *cx, unsigned argc, jsval *vp) { \ 100 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \ 101 | JSObject* obj = args.thisv().toObjectOrNull(); \ 102 | klass* cobj = (klass*)JS_GetPrivate(obj); \ 103 | if (cobj) { \ 104 | return cobj->_js_set_##propName(cx, args); \ 105 | } \ 106 | JS_ReportError(cx, "Invalid setter call for property %s", #propName); \ 107 | return false; \ 108 | } \ 109 | bool klass::_js_set_##propName(JSContext *cx, const JS::CallArgs& args) 110 | 111 | #define JS_BINDED_PROP_ACCESSOR(klass, propName) \ 112 | JS_BINDED_PROP_GET(klass, propName); \ 113 | JS_BINDED_PROP_SET(klass, propName); 114 | 115 | #define JS_BINDED_PROP_DEF_GETTER(klass, propName) \ 116 | JS_PSG(#propName, _js_get_##klass##_##propName, JSPROP_ENUMERATE | JSPROP_PERMANENT) 117 | 118 | #define JS_BINDED_PROP_DEF_ACCESSOR(klass, propName) \ 119 | JS_PSGS(#propName, _js_get_##klass##_##propName, _js_set_##klass##_##propName, JSPROP_ENUMERATE | JSPROP_PERMANENT) 120 | 121 | #define JS_CREATE_UINT_WRAPPED(valOut, propName, val) \ 122 | do { \ 123 | JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); \ 124 | jsval propVal = UINT_TO_JSVAL(val); \ 125 | JS_SetProperty(cx, jsobj, "__" propName, &propVal); \ 126 | valOut = OBJECT_TO_JSVAL(jsobj); \ 127 | } while(0) 128 | 129 | #define JS_GET_UINT_WRAPPED(inVal, propName, out) \ 130 | do { \ 131 | if (inVal.isObject()) {\ 132 | JSObject* jsobj = JSVAL_TO_OBJECT(inVal); \ 133 | jsval outVal; \ 134 | JS_GetProperty(cx, jsobj, "__" propName, &outVal); \ 135 | JS_ValueToECMAUint32(cx, outVal, &out); \ 136 | } else { \ 137 | int32_t tmp; \ 138 | JS_ValueToInt32(cx, inVal, &tmp); \ 139 | out = (uint32_t)tmp; \ 140 | } \ 141 | } while (0) 142 | 143 | #endif /* __XMLHTTPHELPER_H__ */ 144 | -------------------------------------------------------------------------------- /script/jsb_pool.js: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2008-2010 Ricardo Quesada 3 | Copyright (c) 2011-2012 cocos2d-x.org 4 | Copyright (c) 2013-2014 Chukong Technologies Inc. 5 | 6 | http://www.cocos2d-x.org 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | ****************************************************************************/ 26 | 27 | /** 28 | *

29 | * cc.pool is a singleton object serves as an object cache pool.
30 | * It can helps you to improve your game performance for objects which need frequent release and recreate operations
31 | * Some common use case is : 32 | * 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects) 33 | * 2. Blocks in candy crash (massive creation and recreation) 34 | * etc... 35 | *

36 | * 37 | * @example 38 | * var sp = new cc.Sprite("a.png"); 39 | * this.addChild(sp); 40 | * cc.pool.putInPool(sp); 41 | * 42 | * cc.pool.getFromPool(cc.Sprite, "a.png"); 43 | * @class 44 | * @name cc.pool 45 | */ 46 | cc.pool = /** @lends cc.pool# */{ 47 | _pool: {}, 48 | 49 | _releaseCB: function () { 50 | this.release(); 51 | }, 52 | 53 | _autoRelease: function (obj) { 54 | var running = obj._running === undefined ? false : !obj._running; 55 | cc.director.getScheduler().scheduleCallbackForTarget(obj, this._releaseCB, 0, 0, 0, running) 56 | }, 57 | 58 | /** 59 | * Put the obj in pool 60 | * @param obj 61 | */ 62 | putInPool: function (obj) { 63 | var pid = obj.constructor.prototype.__pid; 64 | if (!pid) { 65 | var desc = { writable: true, enumerable: false, configurable: true }; 66 | desc.value = ClassManager.getNewID(); 67 | Object.defineProperty(obj.constructor.prototype, '__pid', desc); 68 | } 69 | if (!this._pool[pid]) { 70 | this._pool[pid] = []; 71 | } 72 | // JSB retain to avoid being auto released 73 | obj.retain && obj.retain(); 74 | // User implementation for disable the object 75 | obj.unuse && obj.unuse(); 76 | this._pool[pid].push(obj); 77 | }, 78 | 79 | /** 80 | * Check if this kind of obj has already in pool 81 | * @param objClass 82 | * @returns {boolean} if this kind of obj is already in pool return true,else return false; 83 | */ 84 | hasObject: function (objClass) { 85 | var pid = objClass.prototype.__pid; 86 | var list = this._pool[pid]; 87 | if (!list || list.length == 0) { 88 | return false; 89 | } 90 | return true; 91 | }, 92 | 93 | /** 94 | * Remove the obj if you want to delete it; 95 | * @param obj 96 | */ 97 | removeObject: function (obj) { 98 | var pid = obj.constructor.prototype.__pid; 99 | if (pid) { 100 | var list = this._pool[pid]; 101 | if (list) { 102 | for (var i = 0; i < list.length; i++) { 103 | if (obj === list[i]) { 104 | // JSB release to avoid memory leak 105 | obj.release && obj.release(); 106 | list.splice(i, 1); 107 | } 108 | } 109 | } 110 | } 111 | }, 112 | 113 | /** 114 | * Get the obj from pool 115 | * @param args 116 | * @returns {*} call the reuse function an return the obj 117 | */ 118 | getFromPool: function (objClass/*,args*/) { 119 | if (this.hasObject(objClass)) { 120 | var pid = objClass.prototype.__pid; 121 | var list = this._pool[pid]; 122 | var args = Array.prototype.slice.call(arguments); 123 | args.shift(); 124 | var obj = list.pop(); 125 | // User implementation for re-enable the object 126 | obj.reuse && obj.reuse.apply(obj, args); 127 | // JSB release to avoid memory leak 128 | cc.sys.isNative && obj.release && this._autoRelease(obj); 129 | return obj; 130 | } 131 | }, 132 | 133 | /** 134 | * remove all objs in pool and reset the pool 135 | */ 136 | drainAllPools: function () { 137 | for (var i in this._pool) { 138 | for (var j = 0; j < this._pool[i].length; j++) { 139 | var obj = this._pool[i][j]; 140 | // JSB release to avoid memory leak 141 | obj.release && obj.release(); 142 | } 143 | } 144 | this._pool = {}; 145 | } 146 | }; -------------------------------------------------------------------------------- /manual/chipmunk/js_bindings_chipmunk_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | 25 | #ifndef __js_bindings_chipmunk_manual 26 | #define __js_bindings_chipmunk_manual 27 | 28 | #include "jsapi.h" 29 | #include "js_bindings_config.h" 30 | #include "js_manual_conversions.h" 31 | #include "ScriptingCore.h" 32 | #ifdef JSB_INCLUDE_CHIPMUNK 33 | 34 | #include "chipmunk_private.h" 35 | #include "js_bindings_chipmunk_auto_classes.h" 36 | 37 | // Free Functions 38 | bool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); 39 | bool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); 40 | 41 | bool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp); 42 | bool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp); 43 | 44 | bool JSB_cpBodyGetUserData(JSContext *cx, uint32_t argc, jsval *vp); 45 | bool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp); 46 | 47 | // poly related 48 | bool JSB_cpAreaForPoly(JSContext *cx, uint32_t argc, jsval *vp); 49 | bool JSB_cpMomentForPoly(JSContext *cx, uint32_t argc, jsval *vp); 50 | bool JSB_cpCentroidForPoly(JSContext *cx, uint32_t argc, jsval *vp); 51 | bool JSB_cpRecenterPoly(JSContext *cx, uint32_t argc, jsval *vp); 52 | 53 | // "Methods" from the OO API 54 | bool JSB_cpSpace_setDefaultCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); 55 | bool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); 56 | bool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); 57 | 58 | // manually wrapped for rooting/unrooting purposes 59 | bool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp); 60 | bool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp); 61 | bool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp); 62 | bool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp); 63 | bool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp); 64 | bool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp); 65 | bool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp); 66 | bool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp); 67 | bool JSB_cpSpace_segmentQueryFirst(JSContext *cx, uint32_t argc, jsval *vp); 68 | bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *vp); 69 | bool JSB_cpSpace_eachShape(JSContext *cx, uint32_t argc, jsval *vp); 70 | bool JSB_cpSpace_eachBody(JSContext *cx, uint32_t argc, jsval *vp); 71 | bool JSB_cpSpace_eachConstraint(JSContext *cx, uint32_t argc, jsval *vp); 72 | bool JSB_cpSpace_pointQuery(JSContext *cx, uint32_t argc, jsval *vp); 73 | bool JSB_cpSpace_nearestPointQuery(JSContext *cx, uint32_t argc, jsval *vp); 74 | bool JSB_cpSpace_segmentQuery(JSContext *cx, uint32_t argc, jsval *vp); 75 | bool JSB_cpSpace_bbQuery(JSContext *cx, uint32_t argc, jsval *vp); 76 | bool JSB_cpSpace_addPostStepCallback(JSContext *cx, uint32_t argc, jsval *vp); 77 | 78 | bool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp); 79 | bool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp); 80 | 81 | bool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp); 82 | bool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp); 83 | bool JSB_cpBody_setUserData(JSContext *cx, uint32_t argc, jsval *vp); 84 | 85 | bool JSB_cpBody_eachShape(JSContext *cx, uint32_t argc, jsval *vp); 86 | bool JSB_cpBody_eachConstraint(JSContext *cx, uint32_t argc, jsval *vp); 87 | bool JSB_cpBody_eachArbiter(JSContext *cx, uint32_t argc, jsval *vp); 88 | 89 | 90 | // convertions 91 | 92 | jsval cpBB_to_jsval(JSContext *cx, cpBB bb ); 93 | bool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ); 94 | bool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numVerts); 95 | bool jsval_to_cpVect( JSContext *cx, jsval vp, cpVect *out ); 96 | jsval cpVect_to_jsval( JSContext *cx, cpVect p ); 97 | 98 | // Object Oriented Chipmunk 99 | void JSB_cpBase_createClass(JSContext* cx, JS::HandleObject globalObj, const char * name ); 100 | extern JSObject* JSB_cpBase_object; 101 | extern JSClass* JSB_cpBase_class; 102 | extern void register_CCPhysicsSprite(JSContext *cx, JS::HandleObject obj); 103 | extern void register_CCPhysicsDebugNode(JSContext *cx, JS::HandleObject obj); 104 | 105 | // Manual constructor / destructors 106 | bool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp); 107 | void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *obj); 108 | 109 | #endif // JSB_INCLUDE_CHIPMUNK 110 | 111 | #endif // __js_bindings_chipmunk_manual 112 | -------------------------------------------------------------------------------- /script/physicsSprite/jsb_physicsSprite.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | // move from extension 24 | // start 25 | //PhysicsDebugNode 26 | cc.PhysicsDebugNode.create = function( space ) { 27 | var s = space; 28 | if( space.handle !== undefined ) 29 | s = space.handle; 30 | return cc.PhysicsDebugNode._create( s ); 31 | }; 32 | 33 | cc.PhysicsDebugNode.prototype._ctor = function(space){ 34 | this.init(); 35 | var s = space; 36 | if( space.handle !== undefined ) 37 | s = space.handle; 38 | this.setSpace(s); 39 | }; 40 | 41 | cc.PhysicsDebugNode.prototype.setSpace = function( space ) { 42 | var s = space; 43 | if( space.handle !== undefined ) 44 | s = space.handle; 45 | return this._setSpace( s ); 46 | }; 47 | 48 | // physicsSprite 49 | cc.PhysicsSprite.prototype.setBody = function( body ) { 50 | var b = body; 51 | if( body.handle !== undefined ) 52 | b = body.handle; 53 | return this._setCPBody( b ); 54 | }; 55 | 56 | cc.PhysicsSprite.prototype.getBody = function() { 57 | return this.getCPBody(); 58 | }; 59 | // end 60 | 61 | // move from property_impls 62 | // start 63 | _safeExtend(cc.PhysicsSprite.prototype, { 64 | setPositionX: function(x) { 65 | this.setPosition( cc.p(x, this.getPositionY()) ); 66 | }, 67 | setPositionY: function(y) { 68 | this.setPosition( cc.p(this.getPositionX(), y) ); 69 | } 70 | }); 71 | // end 72 | 73 | // move from property_apis 74 | // start 75 | var _proto = cc.PhysicsSprite.prototype; 76 | cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody); 77 | cc.defineGetterSetter(_proto, "x", _proto.getPositionX, _proto.setPositionX); 78 | cc.defineGetterSetter(_proto, "y", _proto.getPositionY, _proto.setPositionY); 79 | cc.defineGetterSetter(_proto, "rotation", _proto.getRotation, _proto.setRotation); 80 | cc.defineGetterSetter(_proto, "dirty", _proto.isDirty, _proto.setDirty); 81 | // end 82 | 83 | // move from create_apis 84 | // start 85 | /************************ PhysicsSprite *************************/ 86 | var _p = cc.PhysicsSprite.prototype; 87 | _p._ctor = function(fileName, rect){ 88 | if (fileName === undefined) { 89 | cc.PhysicsSprite.prototype.init.call(this); 90 | }else if (typeof(fileName) === "string") { 91 | if (fileName[0] === "#") { 92 | //init with a sprite frame name 93 | var frameName = fileName.substr(1, fileName.length - 1); 94 | var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName); 95 | this.initWithSpriteFrame(spriteFrame); 96 | } else { 97 | //init with filename and rect 98 | if(rect) 99 | this.initWithFile(fileName, rect); 100 | else 101 | this.initWithFile(fileName); 102 | } 103 | }else if (typeof(fileName) === "object") { 104 | if (fileName instanceof cc.Texture2D) { 105 | //init with texture and rect 106 | this.initWithTexture(fileName, rect); 107 | } else if (fileName instanceof cc.SpriteFrame) { 108 | //init with a sprite frame 109 | this.initWithSpriteFrame(fileName); 110 | } 111 | } 112 | }; 113 | 114 | cc.PhysicsSprite._create = cc.PhysicsSprite.create; 115 | cc.PhysicsSprite.create = function (fileName, rect) { 116 | var sprite; 117 | 118 | if (arguments.length == 0) { 119 | sprite = cc.PhysicsSprite._create(); 120 | return sprite; 121 | } 122 | 123 | if (typeof(fileName) === "string") { 124 | if (fileName[0] === "#") { 125 | //init with a sprite frame name 126 | var frameName = fileName.substr(1, fileName.length - 1); 127 | var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName); 128 | sprite = cc.PhysicsSprite.createWithSpriteFrame(spriteFrame); 129 | } else { 130 | // Create with filename and rect 131 | sprite = rect ? cc.PhysicsSprite._create(fileName, rect) : cc.PhysicsSprite._create(fileName); 132 | } 133 | if (sprite) 134 | return sprite; 135 | else return null; 136 | } 137 | 138 | if (typeof(fileName) === "object") { 139 | if (fileName instanceof cc.Texture2D) { 140 | //init with texture and rect 141 | sprite = rect ? cc.PhysicsSprite.createWithTexture(fileName, rect) : cc.PhysicsSprite.createWithTexture(fileName); 142 | } else if (fileName instanceof cc.SpriteFrame) { 143 | //init with a sprite frame 144 | sprite = cc.PhysicsSprite.createWithSpriteFrame(fileName) 145 | } 146 | if (sprite) 147 | return sprite; 148 | else return null; 149 | } 150 | 151 | return null; 152 | }; 153 | // end 154 | 155 | -------------------------------------------------------------------------------- /manual/network/XMLHTTPRequest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by Rolando Abarca 2012. 3 | * Copyright (c) 2012 Rolando Abarca. All rights reserved. 4 | * Copyright (c) 2013 Zynga Inc. All rights reserved. 5 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 6 | * 7 | * Heavy based on: https://github.com/funkaster/FakeWebGL/blob/master/FakeWebGL/WebGL/XMLHTTPRequest.h 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | 28 | 29 | #ifndef __FAKE_XMLHTTPREQUEST_H__ 30 | #define __FAKE_XMLHTTPREQUEST_H__ 31 | 32 | #include "jsapi.h" 33 | #include "jsfriendapi.h" 34 | #include "network/HttpClient.h" 35 | #include "js_bindings_config.h" 36 | #include "ScriptingCore.h" 37 | #include "jsb_helper.h" 38 | 39 | class MinXmlHttpRequest : public cocos2d::Ref 40 | { 41 | public: 42 | enum class ResponseType 43 | { 44 | STRING, 45 | ARRAY_BUFFER, 46 | BLOB, 47 | DOCUMENT, 48 | JSON 49 | }; 50 | 51 | // Ready States (http://www.w3.org/TR/XMLHttpRequest/#interface-xmlhttprequest) 52 | static const unsigned short UNSENT = 0; 53 | static const unsigned short OPENED = 1; 54 | static const unsigned short HEADERS_RECEIVED = 2; 55 | static const unsigned short LOADING = 3; 56 | static const unsigned short DONE = 4; 57 | 58 | MinXmlHttpRequest(); 59 | ~MinXmlHttpRequest(); 60 | 61 | JS_BINDED_CLASS_GLUE(MinXmlHttpRequest); 62 | JS_BINDED_CONSTRUCTOR(MinXmlHttpRequest); 63 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onloadstart); 64 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onreadystatechange); 65 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onabort); 66 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onerror); 67 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onload); 68 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onloadend); 69 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, ontimeout); 70 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, withCredentials); 71 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, upload); 72 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, timeout); 73 | JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, responseType); 74 | JS_BINDED_PROP_GET(MinXmlHttpRequest, readyState); 75 | JS_BINDED_PROP_GET(MinXmlHttpRequest, status); 76 | JS_BINDED_PROP_GET(MinXmlHttpRequest, statusText); 77 | JS_BINDED_PROP_GET(MinXmlHttpRequest, responseText); 78 | JS_BINDED_PROP_GET(MinXmlHttpRequest, response); 79 | JS_BINDED_PROP_GET(MinXmlHttpRequest, responseXML); 80 | JS_BINDED_FUNC(MinXmlHttpRequest, open); 81 | JS_BINDED_FUNC(MinXmlHttpRequest, send); 82 | JS_BINDED_FUNC(MinXmlHttpRequest, abort); 83 | JS_BINDED_FUNC(MinXmlHttpRequest, getAllResponseHeaders); 84 | JS_BINDED_FUNC(MinXmlHttpRequest, getResponseHeader); 85 | JS_BINDED_FUNC(MinXmlHttpRequest, setRequestHeader); 86 | JS_BINDED_FUNC(MinXmlHttpRequest, overrideMimeType); 87 | 88 | void handle_requestResponse(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response); 89 | 90 | void update(float dt); 91 | private: 92 | void _gotHeader(std::string header); 93 | void _setRequestHeader(const char* field, const char* value); 94 | void _setHttpRequestHeader(); 95 | void _setHttpRequestData(const char *data, size_t len); 96 | void _sendRequest(JSContext *cx); 97 | void _notify(JSObject * callback); 98 | 99 | std::string _url; 100 | JSContext* _cx; 101 | std::string _meth; 102 | std::string _type; 103 | char* _data; 104 | uint32_t _dataSize; 105 | JS::Heap _onloadstartCallback; 106 | JS::Heap _onabortCallback; 107 | JS::Heap _onerrorCallback; 108 | JS::Heap _onloadCallback; 109 | JS::Heap _onloadendCallback; 110 | JS::Heap _ontimeoutCallback; 111 | JS::Heap _onreadystateCallback; 112 | int _readyState; 113 | int _status; 114 | std::string _statusText; 115 | ResponseType _responseType; 116 | unsigned long long _timeout; 117 | float _elapsedTime; 118 | bool _isAsync; 119 | cocos2d::network::HttpRequest* _httpRequest; 120 | bool _isNetwork; 121 | bool _withCredentialsValue; 122 | bool _errorFlag; 123 | std::unordered_map _httpHeader; 124 | std::unordered_map _requestHeader; 125 | bool _isAborted; 126 | cocos2d::Scheduler* _scheduler; 127 | }; 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /auto/jsb_cocos2dx_3d_extension_auto.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __cocos2dx_3d_extension_h__ 2 | #define __cocos2dx_3d_extension_h__ 3 | 4 | #include "jsapi.h" 5 | #include "jsfriendapi.h" 6 | 7 | 8 | extern JSClass *jsb_cocos2d_ParticleSystem3D_class; 9 | extern JSObject *jsb_cocos2d_ParticleSystem3D_prototype; 10 | 11 | bool js_cocos2dx_3d_extension_ParticleSystem3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); 12 | void js_cocos2dx_3d_extension_ParticleSystem3D_finalize(JSContext *cx, JSObject *obj); 13 | void js_register_cocos2dx_3d_extension_ParticleSystem3D(JSContext *cx, JS::HandleObject global); 14 | void register_all_cocos2dx_3d_extension(JSContext* cx, JS::HandleObject obj); 15 | bool js_cocos2dx_3d_extension_ParticleSystem3D_resumeParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); 16 | bool js_cocos2dx_3d_extension_ParticleSystem3D_startParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); 17 | bool js_cocos2dx_3d_extension_ParticleSystem3D_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); 18 | bool js_cocos2dx_3d_extension_ParticleSystem3D_isKeepLocal(JSContext *cx, uint32_t argc, jsval *vp); 19 | bool js_cocos2dx_3d_extension_ParticleSystem3D_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); 20 | bool js_cocos2dx_3d_extension_ParticleSystem3D_getParticleQuota(JSContext *cx, uint32_t argc, jsval *vp); 21 | bool js_cocos2dx_3d_extension_ParticleSystem3D_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); 22 | bool js_cocos2dx_3d_extension_ParticleSystem3D_pauseParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); 23 | bool js_cocos2dx_3d_extension_ParticleSystem3D_getState(JSContext *cx, uint32_t argc, jsval *vp); 24 | bool js_cocos2dx_3d_extension_ParticleSystem3D_getAliveParticleCount(JSContext *cx, uint32_t argc, jsval *vp); 25 | bool js_cocos2dx_3d_extension_ParticleSystem3D_setParticleQuota(JSContext *cx, uint32_t argc, jsval *vp); 26 | bool js_cocos2dx_3d_extension_ParticleSystem3D_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); 27 | bool js_cocos2dx_3d_extension_ParticleSystem3D_stopParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); 28 | bool js_cocos2dx_3d_extension_ParticleSystem3D_setKeepLocal(JSContext *cx, uint32_t argc, jsval *vp); 29 | bool js_cocos2dx_3d_extension_ParticleSystem3D_ParticleSystem3D(JSContext *cx, uint32_t argc, jsval *vp); 30 | 31 | extern JSClass *jsb_cocos2d_PUParticleSystem3D_class; 32 | extern JSObject *jsb_cocos2d_PUParticleSystem3D_prototype; 33 | 34 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); 35 | void js_cocos2dx_3d_extension_PUParticleSystem3D_finalize(JSContext *cx, JSObject *obj); 36 | void js_register_cocos2dx_3d_extension_PUParticleSystem3D(JSContext *cx, JS::HandleObject global); 37 | void register_all_cocos2dx_3d_extension(JSContext* cx, JS::HandleObject obj); 38 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getParticleSystemScaleVelocity(JSContext *cx, uint32_t argc, jsval *vp); 39 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedSystemQuota(JSContext *cx, uint32_t argc, jsval *vp); 40 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultDepth(JSContext *cx, uint32_t argc, jsval *vp); 41 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedSystemQuota(JSContext *cx, uint32_t argc, jsval *vp); 42 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_clearAllParticles(JSContext *cx, uint32_t argc, jsval *vp); 43 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getMaterialName(JSContext *cx, uint32_t argc, jsval *vp); 44 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_calulateRotationOffset(JSContext *cx, uint32_t argc, jsval *vp); 45 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getMaxVelocity(JSContext *cx, uint32_t argc, jsval *vp); 46 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_forceUpdate(JSContext *cx, uint32_t argc, jsval *vp); 47 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getTimeElapsedSinceStart(JSContext *cx, uint32_t argc, jsval *vp); 48 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedEmitterQuota(JSContext *cx, uint32_t argc, jsval *vp); 49 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_isMarkedForEmission(JSContext *cx, uint32_t argc, jsval *vp); 50 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultWidth(JSContext *cx, uint32_t argc, jsval *vp); 51 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedEmitterQuota(JSContext *cx, uint32_t argc, jsval *vp); 52 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_setMarkedForEmission(JSContext *cx, uint32_t argc, jsval *vp); 53 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_clone(JSContext *cx, uint32_t argc, jsval *vp); 54 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultWidth(JSContext *cx, uint32_t argc, jsval *vp); 55 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_copyAttributesTo(JSContext *cx, uint32_t argc, jsval *vp); 56 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_setMaterialName(JSContext *cx, uint32_t argc, jsval *vp); 57 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getParentParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); 58 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_setMaxVelocity(JSContext *cx, uint32_t argc, jsval *vp); 59 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultHeight(JSContext *cx, uint32_t argc, jsval *vp); 60 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedPosition(JSContext *cx, uint32_t argc, jsval *vp); 61 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_rotationOffset(JSContext *cx, uint32_t argc, jsval *vp); 62 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedOrientation(JSContext *cx, uint32_t argc, jsval *vp); 63 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllEmitter(JSContext *cx, uint32_t argc, jsval *vp); 64 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_setParticleSystemScaleVelocity(JSContext *cx, uint32_t argc, jsval *vp); 65 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedScale(JSContext *cx, uint32_t argc, jsval *vp); 66 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultHeight(JSContext *cx, uint32_t argc, jsval *vp); 67 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllListener(JSContext *cx, uint32_t argc, jsval *vp); 68 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultDepth(JSContext *cx, uint32_t argc, jsval *vp); 69 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_create(JSContext *cx, uint32_t argc, jsval *vp); 70 | bool js_cocos2dx_3d_extension_PUParticleSystem3D_PUParticleSystem3D(JSContext *cx, uint32_t argc, jsval *vp); 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /script/extension/jsb_ext_property_apis.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | var _proto = cc.Control.prototype; 24 | cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); 25 | cc.defineGetterSetter(_proto, "state", _proto.getState); 26 | cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); 27 | cc.defineGetterSetter(_proto, "selected", _proto.isSelected, _proto.setSelected); 28 | cc.defineGetterSetter(_proto, "highlighted", _proto.isHighlighted, _proto.setHighlighted); 29 | 30 | _proto = cc.ControlButton.prototype; 31 | cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); 32 | cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); 33 | cc.defineGetterSetter(_proto, "adjustBackgroundImage", _proto.getAdjustBackgroundImage, _proto.setAdjustBackgroundImage); 34 | cc.defineGetterSetter(_proto, "zoomOnTouchDown", _proto.getZoomOnTouchDown, _proto.setZoomOnTouchDown); 35 | cc.defineGetterSetter(_proto, "preferredSize", _proto.getPreferredSize, _proto.setPreferredSize); 36 | cc.defineGetterSetter(_proto, "labelAnchor", _proto.getLabelAnchorPoint, _proto.setLabelAnchorPoint); 37 | 38 | _proto = cc.ControlColourPicker.prototype; 39 | cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); 40 | cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); 41 | cc.defineGetterSetter(_proto, "background", _proto.getBackground); 42 | 43 | _proto = cc.ControlHuePicker.prototype; 44 | cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); 45 | cc.defineGetterSetter(_proto, "hue", _proto.getHue, _proto.setHue); 46 | cc.defineGetterSetter(_proto, "huePercent", _proto.getHuePercentage, _proto.setHuePercentage); 47 | cc.defineGetterSetter(_proto, "background", _proto.getBackground); 48 | cc.defineGetterSetter(_proto, "slider", _proto.getSlider); 49 | cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); 50 | 51 | _proto = cc.ControlPotentiometer.prototype; 52 | cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); 53 | cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); 54 | cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); 55 | cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); 56 | cc.defineGetterSetter(_proto, "progressTimer", _proto.getProgressTimer, _proto.setProgressTimer); 57 | cc.defineGetterSetter(_proto, "thumbSprite", _proto.getThumbSprite, _proto.setThumbSprite); 58 | cc.defineGetterSetter(_proto, "prevLocation", _proto.getPreviousLocation, _proto.setPreviousLocation); 59 | 60 | _proto = cc.ControlSaturationBrightnessPicker.prototype; 61 | cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); 62 | cc.defineGetterSetter(_proto, "saturation", _proto.getSaturation); 63 | cc.defineGetterSetter(_proto, "brightness", _proto.getBrightness); 64 | cc.defineGetterSetter(_proto, "background", _proto.getBackground); 65 | cc.defineGetterSetter(_proto, "overlay", _proto.getOverlay); 66 | cc.defineGetterSetter(_proto, "shadow", _proto.getShadow); 67 | cc.defineGetterSetter(_proto, "slider", _proto.getSlider); 68 | cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); 69 | 70 | _proto = cc.ControlSlider.prototype; 71 | cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); 72 | cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); 73 | cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); 74 | cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); 75 | cc.defineGetterSetter(_proto, "minAllowedValue", _proto.getMinimumAllowedValue, _proto.setMinimumAllowedValue); 76 | cc.defineGetterSetter(_proto, "maxAllowedValue", _proto.getMaximumAllowedValue, _proto.setMaximumAllowedValue); 77 | cc.defineGetterSetter(_proto, "thumbSprite", _proto.getThumbSprite); 78 | cc.defineGetterSetter(_proto, "progressSprite", _proto.getProgressSprite); 79 | cc.defineGetterSetter(_proto, "backgroundSprite", _proto.getBackgroundSprite); 80 | 81 | _proto = cc.ControlSwitch.prototype; 82 | cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); 83 | 84 | _proto = cc.ScrollView.prototype; 85 | cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); 86 | cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); 87 | cc.defineGetterSetter(_proto, "direction", _proto.getDirection, _proto.setDirection); 88 | 89 | _proto = cc.ControlStepper.prototype; 90 | cc.defineGetterSetter(_proto, "wraps", _proto.getWraps, _proto.setWraps); 91 | cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); 92 | cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); 93 | cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); 94 | cc.defineGetterSetter(_proto, "stepValue", _proto.getStepValue, _proto.setStepValue); 95 | cc.defineGetterSetter(_proto, "continuous", _proto.isContinuous); 96 | cc.defineGetterSetter(_proto, "minusSprite", _proto.getMinusSprite, _proto.setMinusSprite); 97 | cc.defineGetterSetter(_proto, "plusSprite", _proto.getPlusSprite, _proto.setPlusSprite); 98 | cc.defineGetterSetter(_proto, "minusLabel", _proto.getMinusLabel, _proto.setMinusLabel); 99 | cc.defineGetterSetter(_proto, "plusSLabel", _proto.getPlusSLabel, _proto.setPlusSLabel); 100 | 101 | _proto = cc.TableViewCell.prototype; 102 | cc.defineGetterSetter(_proto, "objectId", _proto.getObjectID, _proto.setObjectID); 103 | -------------------------------------------------------------------------------- /script/ccui/jsb_ccui_create_apis.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | ccui.Widget.prototype.init = ccui.Widget.prototype._init; 24 | ccui.RichText.prototype.init = function(){ 25 | ccui.Widget.prototype.init.call(this); 26 | }; 27 | ccui.Slider.prototype.init = function(){ 28 | ccui.Widget.prototype.init.call(this); 29 | this.setTouchEnabled(true); 30 | }; 31 | 32 | ccui.Widget.prototype._ctor 33 | = ccui.RichText.prototype._ctor 34 | = ccui.Slider.prototype._ctor 35 | = ccui.Layout.prototype._ctor 36 | = ccui.ListView.prototype._ctor 37 | = ccui.PageView.prototype._ctor 38 | = ccui.ScrollView.prototype._ctor 39 | = function(){ 40 | this.init(); 41 | } 42 | 43 | ccui.Button.prototype._ctor = function (normalImage, selectedImage, disableImage, texType) { 44 | if(texType !== undefined) 45 | ccui.Button.prototype.init.call(this, normalImage, selectedImage, disableImage, texType); 46 | else if(disableImage !== undefined) 47 | ccui.Button.prototype.init.call(this, normalImage, selectedImage, disableImage); 48 | else if(selectedImage !== undefined) 49 | ccui.Button.prototype.init.call(this, normalImage, selectedImage); 50 | else if(normalImage !== undefined) 51 | ccui.Button.prototype.init.call(this, normalImage); 52 | else 53 | ccui.Widget.prototype.init.call(this); 54 | 55 | this.setTouchEnabled(true); 56 | }; 57 | 58 | ccui.CheckBox.prototype._ctor = function (backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType) { 59 | if (frontCrossDisabled !== undefined) { 60 | texType = texType || ccui.Widget.LOCAL_TEXTURE; 61 | ccui.CheckBox.prototype.init.call(this, backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType); 62 | }else if(backGroundSelected !== undefined){ 63 | texType = ccui.Widget.LOCAL_TEXTURE; 64 | cross = backGroundSelected; 65 | backGroundSelected = backGroundDisabled = frontCrossDisabled = backGround; 66 | ccui.CheckBox.prototype.init.call(this, backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType); 67 | } 68 | else { 69 | ccui.Widget.prototype.init.call(this); 70 | } 71 | 72 | this.setSelected(false); 73 | this.setTouchEnabled(true); 74 | }; 75 | 76 | ccui.ImageView.prototype._ctor = function(imageFileName, texType){ 77 | if(imageFileName !== undefined){ 78 | texType = texType || ccui.Widget.LOCAL_TEXTURE; 79 | ccui.ImageView.prototype._init.call(this, imageFileName, texType); 80 | } 81 | else 82 | ccui.Widget.prototype.init.call(this); 83 | } 84 | 85 | ccui.LoadingBar.prototype._ctor = function(textureName, percentage){ 86 | ccui.Widget.prototype.init.call(this); 87 | 88 | if(textureName !== undefined) 89 | this.loadTexture(textureName); 90 | if(percentage !== undefined) 91 | this.setPercent(percentage); 92 | }; 93 | 94 | ccui.TextAtlas.prototype._ctor = function(stringValue, charMapFile, itemWidth, itemHeight, startCharMap){ 95 | ccui.Widget.prototype.init.call(this); 96 | startCharMap !== undefined && this.setProperty(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); 97 | }; 98 | 99 | ccui.Text.prototype._ctor = function(textContent, fontName, fontSize){ 100 | if(fontSize !== undefined) 101 | ccui.Text.prototype.init.call(this, textContent, fontName, fontSize); 102 | else 103 | ccui.Widget.prototype.init.call(this); 104 | }; 105 | 106 | ccui.TextBMFont.prototype._ctor = function(text, filename){ 107 | ccui.Widget.prototype.init.call(this); 108 | 109 | if(filename !== undefined){ 110 | this.setFntFile(filename); 111 | this.setString(text); 112 | } 113 | }; 114 | 115 | ccui.TextField.prototype._ctor = function(placeholder, fontName, fontSize){ 116 | ccui.Widget.prototype.init.call(this); 117 | this.setTouchEnabled(true); 118 | 119 | if (placeholder !== undefined) 120 | this.setPlaceHolder(placeholder); 121 | if (fontName !== undefined) 122 | this.setFontName(fontName); 123 | if (fontSize !== undefined) 124 | this.setFontSize(fontSize); 125 | }; 126 | 127 | ccui.RichElementText.prototype._ctor = function(tag, color, opacity, text, fontName, fontSize){ 128 | fontSize !== undefined && this.init(tag, color, opacity, text, fontName, fontSize); 129 | }; 130 | 131 | ccui.RichElementImage.prototype._ctor = function(tag, color, opacity, filePath){ 132 | filePath !== undefined && this.init(tag, color, opacity, filePath); 133 | }; 134 | 135 | ccui.RichElementCustomNode.prototype._ctor = function(tag, color, opacity, customNode){ 136 | customNode !== undefined && this.init(tag, color, opacity, customNode); 137 | }; 138 | 139 | cc.Scale9Sprite.prototype._ctor = function(file, rect, capInsets){ 140 | rect = rect || cc.rect(0, 0, 0, 0); 141 | capInsets = capInsets || cc.rect(0, 0, 0, 0); 142 | if(file != undefined){ 143 | if(file instanceof cc.SpriteFrame) 144 | this.initWithSpriteFrame(file, rect); 145 | else{ 146 | var frame = cc.spriteFrameCache.getSpriteFrame(file); 147 | if(frame != null) 148 | this.initWithSpriteFrame(frame, rect); 149 | else 150 | this.initWithFile(file, rect, capInsets); 151 | } 152 | }else{ 153 | this.init(); 154 | } 155 | }; 156 | 157 | cc.EditBox.prototype._ctor = function(size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg){ 158 | normal9SpriteBg && this.initWithSizeAndBackgroundSprite(size, normal9SpriteBg); 159 | }; 160 | -------------------------------------------------------------------------------- /manual/js_bindings_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Zynga Inc. 3 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | * THE SOFTWARE. 22 | */ 23 | 24 | 25 | #ifndef __JS_BINDINGS_CONFIG_H 26 | #define __JS_BINDINGS_CONFIG_H 27 | 28 | 29 | /** @def JSB_ASSERT_ON_FAIL 30 | Whether or not to assert when the arguments or conversions are incorrect. 31 | It is recommened to turn it off in Release mode. 32 | */ 33 | #ifndef JSB_ASSERT_ON_FAIL 34 | #define JSB_ASSERT_ON_FAIL 0 35 | #endif 36 | 37 | 38 | #if JSB_ASSERT_ON_FAIL 39 | #define JSB_PRECONDITION( condition, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) 40 | #define JSB_PRECONDITION2( condition, context, ret_value, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) 41 | #define ASSERT( condition, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) 42 | 43 | #else 44 | #define JSB_PRECONDITION( condition, ...) do { \ 45 | if( ! (condition) ) { \ 46 | cocos2d::log("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ 47 | cocos2d::log(__VA_ARGS__); \ 48 | JSContext* globalContext = ScriptingCore::getInstance()->getGlobalContext(); \ 49 | if( ! JS_IsExceptionPending( globalContext ) ) { \ 50 | JS_ReportError( globalContext, __VA_ARGS__ ); \ 51 | } \ 52 | return false; \ 53 | } \ 54 | } while(0) 55 | #define JSB_PRECONDITION2( condition, context, ret_value, ...) do { \ 56 | if( ! (condition) ) { \ 57 | cocos2d::log("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ 58 | cocos2d::log(__VA_ARGS__); \ 59 | if( ! JS_IsExceptionPending( context ) ) { \ 60 | JS_ReportError( context, __VA_ARGS__ ); \ 61 | } \ 62 | return ret_value; \ 63 | } \ 64 | } while(0) 65 | #define ASSERT( condition, error_msg) do { \ 66 | if( ! (condition) ) { \ 67 | CCLOG("jsb: ERROR in %s: %s\n", __FUNCTION__, error_msg); \ 68 | return false; \ 69 | } \ 70 | } while(0) 71 | #endif 72 | 73 | #define JSB_PRECONDITION3( condition, context, ret_value, ...) do { \ 74 | if( ! (condition) ) return (ret_value); \ 75 | } while(0) 76 | 77 | 78 | /** @def JSB_REPRESENT_LONGLONG_AS_STR 79 | When JSB_REPRESENT_LONGLONG_AS_STR is defined, the long long will be represented as JS strings. 80 | Otherwise they will be represented as an array of two intengers. 81 | It is needed to to use an special representation since there are no 64-bit integers in JS. 82 | Representing the long long as string could be a bit slower, but it is easier to debug from JS. 83 | Enabled by default. 84 | */ 85 | #ifndef JSB_REPRESENT_LONGLONG_AS_STR 86 | #define JSB_REPRESENT_LONGLONG_AS_STR 1 87 | #endif // JSB_REPRESENT_LONGLONG_AS_STR 88 | 89 | 90 | /** @def JSB_INCLUDE_CHIPMUNK 91 | Whether or not it should include JS bindings for Chipmunk 92 | */ 93 | #ifndef JSB_INCLUDE_CHIPMUNK 94 | #define JSB_INCLUDE_CHIPMUNK 1 95 | #endif // JSB_INCLUDE_CHIPMUNK 96 | 97 | 98 | /** @def JSB_INCLUDE_COCOSBUILDERREADER 99 | Whether or not it should include JS bindings for CocosBuilder Reader 100 | */ 101 | #ifndef JSB_INCLUDE_COCOSBUILDERREADER 102 | #define JSB_INCLUDE_COCOSBUILDERREADER 1 103 | #endif // JSB_INCLUDE_COCOSBUILDERREADER 104 | 105 | /** @def JSB_INCLUDE_COCOSDENSHION 106 | Whether or not it should include bindings for CocosDenshion (sound engine) 107 | */ 108 | #ifndef JSB_INCLUDE_COCOSDENSHION 109 | #define JSB_INCLUDE_COCOSDENSHION 1 110 | #endif // JSB_INCLUDE_COCOSDENSHION 111 | 112 | #if JSB_ENABLE_DEBUGGER 113 | #define JSB_ENSURE_AUTOCOMPARTMENT(cx, obj) \ 114 | JSAutoCompartment ac(cx, obj) 115 | #else 116 | #define JSB_ENSURE_AUTOCOMPARTMENT(cx, obj) 117 | #endif 118 | 119 | #define JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET \ 120 | JSAutoCompartment __jsb_ac(ScriptingCore::getInstance()->getGlobalContext(), ScriptingCore::getInstance()->getGlobalObject()); 121 | 122 | 123 | /** @def JSB_INCLUDE_SYSTEM 124 | Whether or not it should include bindings for system components like LocalStorage 125 | */ 126 | #ifndef JSB_INCLUDE_SYSTEM 127 | #define JSB_INCLUDE_SYSTEM 1 128 | #endif // JSB_INCLUDE_SYSTEM 129 | 130 | /** @def JSB_INCLUDE_OPENGL 131 | Whether or not it should include bindings for WebGL / OpenGL ES 2.0 132 | */ 133 | #ifndef JSB_INCLUDE_OPENGL 134 | #define JSB_INCLUDE_OPENGL 1 135 | #endif // JSB_INCLUDE_OPENGL 136 | 137 | /** @def JSB_INCLUDE_XMLHTTP 138 | Whether or not it should include bindings for XmlHttpRequest 139 | */ 140 | #ifndef JSB_INCLUDE_XMLHTTP 141 | #define JSB_INCLUDE_XMLHTTP 1 142 | #endif // JSB_INCLUDE_XMLHTTP 143 | 144 | #ifndef JSB_MAX_STACK_QUOTA 145 | #define JSB_MAX_STACK_QUOTA 500000 146 | #endif // JSB_MAX_STACK_QUOTA 147 | 148 | #endif // __JS_BINDINGS_CONFIG_H 149 | -------------------------------------------------------------------------------- /script/jsb_loaders.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | // 24 | // cocos2d loader plugins. 25 | // 26 | // This helper file should be required after jsb_cocos2d.js 27 | // 28 | 29 | cc._emptyLoader = { 30 | load : function(realUrl, url){ 31 | return null; 32 | } 33 | }; 34 | 35 | cc.loader.register([ 36 | "mp3", "ogg", "wav", "mp4", "m4a", 37 | "font", "eot", "ttf", "woff", "svg" 38 | ], 39 | cc._emptyLoader); 40 | 41 | cc._txtLoader = { 42 | load : function(realUrl, url){ 43 | return jsb.fileUtils.getStringFromFile(realUrl); 44 | } 45 | }; 46 | cc.loader.register(["txt", "xml", "vsh", "fsh", "tmx", "tsx"], cc._txtLoader); 47 | 48 | cc._jsonLoader = { 49 | load : function(realUrl, url){ 50 | var data = jsb.fileUtils.getStringFromFile(realUrl); 51 | try{ 52 | return JSON.parse(data); 53 | }catch(e){ 54 | cc.error(e); 55 | return null; 56 | } 57 | } 58 | }; 59 | cc.loader.register(["json", "ExportJson"], cc._jsonLoader); 60 | 61 | cc._imgLoader = { 62 | load : function(realUrl, url, res, cb){ 63 | cc.loader.loadImg(realUrl, function(err, img){ 64 | if(err) { 65 | cb && cb(err); 66 | return; 67 | } 68 | cc.loader.cache[url] = img; 69 | cb && cb(null, img); 70 | }); 71 | } 72 | }; 73 | cc.loader.register(["png", "jpg", "bmp","jpeg","gif"], cc._imgLoader); 74 | 75 | cc._plistLoader = { 76 | load : function(realUrl, url){ 77 | var content = jsb.fileUtils.getStringFromFile(realUrl); 78 | return cc.plistParser.parse(content); 79 | } 80 | }; 81 | cc.loader.register(["plist"], cc._plistLoader); 82 | 83 | cc._binaryLoader = { 84 | load : function(realUrl, url){ 85 | return cc.loader.loadBinarySync(realUrl); 86 | } 87 | }; 88 | cc.loader.register(["ccbi"], cc._binaryLoader); 89 | 90 | 91 | cc._fntLoader = { 92 | INFO_EXP : /info [^\n]*(\n|$)/gi, 93 | COMMON_EXP : /common [^\n]*(\n|$)/gi, 94 | PAGE_EXP : /page [^\n]*(\n|$)/gi, 95 | CHAR_EXP : /char [^\n]*(\n|$)/gi, 96 | KERNING_EXP : /kerning [^\n]*(\n|$)/gi, 97 | ITEM_EXP : /\w+=[^ \r\n]+/gi, 98 | INT_EXP : /^[\-]?\d+$/, 99 | 100 | _parseStrToObj : function(str){ 101 | var arr = str.match(this.ITEM_EXP); 102 | var obj = {}; 103 | if(arr){ 104 | for(var i = 0, li = arr.length; i < li; i++){ 105 | var tempStr = arr[i]; 106 | var index = tempStr.indexOf("="); 107 | var key = tempStr.substring(0, index); 108 | var value = tempStr.substring(index + 1); 109 | if(value.match(this.INT_EXP)) value = parseInt(value); 110 | else if(value[0] == '"') value = value.substring(1, value.length - 1); 111 | obj[key] = value; 112 | } 113 | } 114 | return obj; 115 | }, 116 | parseFnt : function(fntStr, url){ 117 | var self = this, fnt = {}; 118 | //padding 119 | var infoObj = self._parseStrToObj(fntStr.match(self.INFO_EXP)[0]); 120 | var paddingArr = infoObj["padding"].split(","); 121 | var padding = { 122 | left : parseInt(paddingArr[0]), 123 | top : parseInt(paddingArr[1]), 124 | right : parseInt(paddingArr[2]), 125 | bottom : parseInt(paddingArr[3]) 126 | }; 127 | 128 | //common 129 | var commonObj = self._parseStrToObj(fntStr.match(self.COMMON_EXP)[0]); 130 | fnt.commonHeight = commonObj["lineHeight"]; 131 | if (cc._renderType === cc._RENDER_TYPE_WEBGL) { 132 | var texSize = cc.configuration.getMaxTextureSize(); 133 | if(commonObj["scaleW"] > texSize.width || commonObj["scaleH"] > texSize.height) 134 | cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported"); 135 | } 136 | if(commonObj["pages"] !== 1) cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page"); 137 | 138 | //page 139 | var pageObj = self._parseStrToObj(fntStr.match(self.PAGE_EXP)[0]); 140 | if(pageObj["id"] !== 0) cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found"); 141 | fnt.atlasName = cc.path.changeBasename(url, pageObj["file"]); 142 | 143 | //char 144 | var charLines = fntStr.match(self.CHAR_EXP); 145 | var fontDefDictionary = fnt.fontDefDictionary = {}; 146 | for(var i = 0, li = charLines.length; i < li; i++){ 147 | var charObj = self._parseStrToObj(charLines[i]); 148 | var charId = charObj["id"]; 149 | fontDefDictionary[charId] = { 150 | rect : {x : charObj["x"], y : charObj["y"], width : charObj["width"], height : charObj["height"]}, 151 | xOffset : charObj["xoffset"], 152 | yOffset : charObj["yoffset"], 153 | xAdvance : charObj["xadvance"] 154 | }; 155 | } 156 | 157 | //kerning 158 | var kerningDict = fnt.kerningDict = {}; 159 | var kerningLines = fntStr.match(self.KERNING_EXP); 160 | if(kerningLines){ 161 | for(var i = 0, li = kerningLines.length; i < li; i++){ 162 | var kerningObj = self._parseStrToObj(kerningLines[i]); 163 | kerningDict[(kerningObj["first"] << 16) | (kerningObj["second"] & 0xffff)] = kerningObj["amount"]; 164 | } 165 | } 166 | return fnt; 167 | }, 168 | 169 | load : function(realUrl, url){ 170 | var data = jsb.fileUtils.getStringFromFile(realUrl); 171 | return this.parseFnt(data, url); 172 | } 173 | }; 174 | cc.loader.register(["fnt"], cc._fntLoader); 175 | -------------------------------------------------------------------------------- /script/jsb_debugger.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2014 Chukong Technologies Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | */ 22 | 23 | let promise = null; 24 | var globalDebuggee = null; 25 | 26 | var gTestGlobals = []; 27 | 28 | 29 | // A mock tab list, for use by tests. This simply presents each global in 30 | // gTestGlobals as a tab, and the list is fixed: it never calls its 31 | // onListChanged handler. 32 | // 33 | // As implemented now, we consult gTestGlobals when we're constructed, not 34 | // when we're iterated over, so tests have to add their globals before the 35 | // root actor is created. 36 | function TestTabList(aConnection) { 37 | this.conn = aConnection; 38 | 39 | // An array of actors for each global added with 40 | // DebuggerServer.addTestGlobal. 41 | this._tabActors = []; 42 | 43 | // A pool mapping those actors' names to the actors. 44 | this._tabActorPool = new ActorPool(aConnection); 45 | 46 | for (let global of gTestGlobals) { 47 | let actor = new TestTabActor(aConnection, global); 48 | actor.selected = false; 49 | this._tabActors.push(actor); 50 | this._tabActorPool.addActor(actor); 51 | } 52 | if (this._tabActors.length > 0) { 53 | this._tabActors[0].selected = true; 54 | } 55 | 56 | aConnection.addActorPool(this._tabActorPool); 57 | } 58 | 59 | TestTabList.prototype = { 60 | constructor: TestTabList, 61 | getList: function () { 62 | return promise.resolve([tabActor for (tabActor of this._tabActors)]); 63 | } 64 | }; 65 | 66 | function createRootActor(aConnection) 67 | { 68 | let root = new RootActor(aConnection, 69 | { tabList: new TestTabList(aConnection) }); 70 | root.applicationType = "xpcshell-tests"; 71 | return root; 72 | } 73 | 74 | function TestTabActor(aConnection, aGlobal) 75 | { 76 | this.conn = aConnection; 77 | this._global = aGlobal; 78 | this._threadActor = new ThreadActor(this, this._global); 79 | this.conn.addActor(this._threadActor); 80 | this._attached = false; 81 | this._extraActors = {}; 82 | } 83 | 84 | TestTabActor.prototype = { 85 | constructor: TestTabActor, 86 | actorPrefix: "TestTabActor", 87 | 88 | get window() { 89 | return { wrappedJSObject: this._global }; 90 | }, 91 | 92 | form: function() { 93 | let response = { actor: this.actorID, title: "Hello Cocos2d-X JSB", url: "http://cocos2d-x.org" }; 94 | 95 | // Walk over tab actors added by extensions and add them to a new ActorPool. 96 | let actorPool = new ActorPool(this.conn); 97 | // this._createExtraActors(DebuggerServer.tabActorFactories, actorPool); 98 | if (!actorPool.isEmpty()) { 99 | this._tabActorPool = actorPool; 100 | this.conn.addActorPool(this._tabActorPool); 101 | } 102 | 103 | // this._appendExtraActors(response); 104 | 105 | return response; 106 | }, 107 | 108 | onAttach: function(aRequest) { 109 | this._attached = true; 110 | 111 | let response = { type: "tabAttached", threadActor: this._threadActor.actorID }; 112 | // this._appendExtraActors(response); 113 | 114 | return response; 115 | }, 116 | 117 | onDetach: function(aRequest) { 118 | if (!this._attached) { 119 | return { "error":"wrongState" }; 120 | } 121 | return { type: "detached" }; 122 | }, 123 | 124 | /* Support for DebuggerServer.addTabActor. */ 125 | // _createExtraActors: CommonCreateExtraActors, 126 | // _appendExtraActors: CommonAppendExtraActors, 127 | 128 | // Hooks for use by TestTabActors. 129 | addToParentPool: function(aActor) { 130 | this.conn.addActor(aActor); 131 | }, 132 | 133 | removeFromParentPool: function(aActor) { 134 | this.conn.removeActor(aActor); 135 | } 136 | }; 137 | 138 | TestTabActor.prototype.requestTypes = { 139 | "attach": TestTabActor.prototype.onAttach, 140 | "detach": TestTabActor.prototype.onDetach 141 | }; 142 | 143 | this.processInput = function (inputstr) { 144 | if (!inputstr) { 145 | return; 146 | } 147 | 148 | if (inputstr === "connected") 149 | { 150 | DebuggerServer.createRootActor = (conn => { 151 | return new RootActor(conn, { tabList: new TestTabList(conn) }); 152 | }); 153 | DebuggerServer.init(() => true); 154 | DebuggerServer.openListener(5086); 155 | if (debuggerServer && debuggerServer.onSocketAccepted) 156 | { 157 | var aTransport = { 158 | host: "127.0.0.1", 159 | port: 5086, 160 | openInputStream: function() { 161 | return { 162 | close: function(){} 163 | }; 164 | }, 165 | openOutputStream: function() { 166 | return { 167 | close: function(){}, 168 | write: function(){}, 169 | asyncWait: function(){} 170 | }; 171 | }, 172 | }; 173 | debuggerServer.onSocketAccepted(null, aTransport); 174 | } 175 | return; 176 | } 177 | 178 | if (DebuggerServer && DebuggerServer._transport && DebuggerServer._transport.onDataAvailable) 179 | { 180 | DebuggerServer._transport.onDataAvailable(inputstr); 181 | } 182 | }; 183 | 184 | this._prepareDebugger = function (global) { 185 | 186 | globalDebuggee = global; 187 | require = global.require; 188 | cc = global.cc; 189 | 190 | require('script/debugger/DevToolsUtils.js', "debug"); 191 | require('script/debugger/core/promise.js', "debug"); 192 | require('script/debugger/transport.js', "debug"); 193 | require('script/debugger/actors/root.js', "debug"); 194 | require('script/debugger/actors/script.js', "debug"); 195 | require('script/debugger/main.js', "debug"); 196 | 197 | promise = exports; 198 | //DebuggerServer.addTestGlobal = function(aGlobal) { 199 | gTestGlobals.push(global); 200 | //}; 201 | 202 | }; 203 | 204 | -------------------------------------------------------------------------------- /script/debugger/DevToolsUtils.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | "use strict"; 6 | 7 | function utf16to8(str) { 8 | var out, i, len, c; 9 | 10 | out = ""; 11 | len = str.length; 12 | for(i = 0; i < len; i++) 13 | { 14 | c = str.charCodeAt(i); 15 | if ((c >= 0x0001) && (c <= 0x007F)) 16 | { 17 | out += str.charAt(i); 18 | } 19 | else if (c > 0x07FF) 20 | { 21 | out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); 22 | out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); 23 | out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); 24 | } 25 | else 26 | { 27 | out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); 28 | out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); 29 | } 30 | } 31 | return out; 32 | } 33 | 34 | function utf8to16(str) { 35 | var out, i, len, c; 36 | var char2, char3; 37 | 38 | out = ""; 39 | len = str.length; 40 | i = 0; 41 | while(i < len) { c = str.charCodeAt(i++); switch(c >> 4) 42 | { 43 | case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: 44 | // 0xxxxxxx 45 | out += str.charAt(i-1); 46 | break; 47 | case 12: case 13: 48 | // 110x xxxx 10xx xxxx 49 | char2 = str.charCodeAt(i++); 50 | out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); 51 | break; 52 | case 14: 53 | // 1110 xxxx 10xx xxxx 10xx xxxx 54 | char2 = str.charCodeAt(i++); 55 | char3 = str.charCodeAt(i++); 56 | out += String.fromCharCode(((c & 0x0F) << 12) | 57 | ((char2 & 0x3F) << 6) | 58 | ((char3 & 0x3F) << 0)); 59 | break; 60 | } 61 | } 62 | 63 | return out; 64 | } 65 | 66 | var dump = function(msg) { 67 | log(msg); 68 | }; 69 | 70 | /* General utilities used throughout devtools. */ 71 | 72 | /** 73 | * Turn the error |aError| into a string, without fail. 74 | */ 75 | this.safeErrorString = function safeErrorString(aError) { 76 | try { 77 | let errorString = aError.toString(); 78 | if (typeof errorString === "string") { 79 | // Attempt to attach a stack to |errorString|. If it throws an error, or 80 | // isn't a string, don't use it. 81 | try { 82 | if (aError.stack) { 83 | let stack = aError.stack.toString(); 84 | if (typeof stack === "string") { 85 | errorString += "\nStack: " + stack; 86 | } 87 | } 88 | } catch (ee) { } 89 | 90 | return errorString; 91 | } 92 | } catch (ee) { } 93 | 94 | return ""; 95 | } 96 | 97 | 98 | /** 99 | * Report that |aWho| threw an exception, |aException|. 100 | */ 101 | this.reportException = function reportException(aWho, aException) { 102 | let msg = aWho + " threw an exception: " + safeErrorString(aException); 103 | 104 | dump(msg + "\n"); 105 | 106 | // if (Components.utils.reportError) { 107 | // /* 108 | // * Note that the xpcshell test harness registers an observer for 109 | // * console messages, so when we're running tests, this will cause 110 | // * the test to quit. 111 | // */ 112 | // Components.utils.reportError(msg); 113 | // } 114 | } 115 | 116 | /** 117 | * Given a handler function that may throw, return an infallible handler 118 | * function that calls the fallible handler, and logs any exceptions it 119 | * throws. 120 | * 121 | * @param aHandler function 122 | * A handler function, which may throw. 123 | * @param aName string 124 | * A name for aHandler, for use in error messages. If omitted, we use 125 | * aHandler.name. 126 | * 127 | * (SpiderMonkey does generate good names for anonymous functions, but we 128 | * don't have a way to get at them from JavaScript at the moment.) 129 | */ 130 | this.makeInfallible = function makeInfallible(aHandler, aName) { 131 | if (!aName) 132 | aName = aHandler.name; 133 | 134 | return function (/* arguments */) { 135 | try { 136 | return aHandler.apply(this, arguments); 137 | } catch (ex) { 138 | let who = "Handler function"; 139 | if (aName) { 140 | who += " " + aName; 141 | } 142 | reportException(who, ex); 143 | } 144 | } 145 | } 146 | 147 | const executeSoon = aFn => { 148 | Services.tm.mainThread.dispatch({ 149 | run: this.makeInfallible(aFn) 150 | }, Components.interfaces.nsIThread.DISPATCH_NORMAL); 151 | } 152 | 153 | /** 154 | * Like Array.prototype.forEach, but doesn't cause jankiness when iterating over 155 | * very large arrays by yielding to the browser and continuing execution on the 156 | * next tick. 157 | * 158 | * @param Array aArray 159 | * The array being iterated over. 160 | * @param Function aFn 161 | * The function called on each item in the array. 162 | * @returns Promise 163 | * A promise that is resolved once the whole array has been iterated 164 | * over. 165 | */ 166 | this.yieldingEach = function yieldingEach(aArray, aFn) { 167 | const deferred = promise.defer(); 168 | 169 | let i = 0; 170 | let len = aArray.length; 171 | 172 | (function loop() { 173 | const start = Date.now(); 174 | 175 | while (i < len) { 176 | // Don't block the main thread for longer than 16 ms at a time. To 177 | // maintain 60fps, you have to render every frame in at least 16ms; we 178 | // aren't including time spent in non-JS here, but this is Good 179 | // Enough(tm). 180 | if (Date.now() - start > 16) { 181 | executeSoon(loop); 182 | return; 183 | } 184 | 185 | try { 186 | aFn(aArray[i++]); 187 | } catch (e) { 188 | deferred.reject(e); 189 | return; 190 | } 191 | } 192 | 193 | deferred.resolve(); 194 | }()); 195 | 196 | return deferred.promise; 197 | } 198 | 199 | 200 | /** 201 | * Like XPCOMUtils.defineLazyGetter, but with a |this| sensitive getter that 202 | * allows the lazy getter to be defined on a prototype and work correctly with 203 | * instances. 204 | * 205 | * @param Object aObject 206 | * The prototype object to define the lazy getter on. 207 | * @param String aKey 208 | * The key to define the lazy getter on. 209 | * @param Function aCallback 210 | * The callback that will be called to determine the value. Will be 211 | * called with the |this| value of the current instance. 212 | */ 213 | this.defineLazyPrototypeGetter = 214 | function defineLazyPrototypeGetter(aObject, aKey, aCallback) { 215 | Object.defineProperty(aObject, aKey, { 216 | configurable: true, 217 | get: function() { 218 | const value = aCallback.call(this); 219 | 220 | Object.defineProperty(this, aKey, { 221 | configurable: true, 222 | writable: true, 223 | value: value 224 | }); 225 | 226 | return value; 227 | } 228 | }); 229 | } 230 | 231 | -------------------------------------------------------------------------------- /auto/jsb_cocos2dx_builder_auto.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __cocos2dx_builder_h__ 2 | #define __cocos2dx_builder_h__ 3 | 4 | #include "jsapi.h" 5 | #include "jsfriendapi.h" 6 | 7 | 8 | extern JSClass *jsb_cocosbuilder_CCBAnimationManager_class; 9 | extern JSObject *jsb_cocosbuilder_CCBAnimationManager_prototype; 10 | 11 | bool js_cocos2dx_builder_CCBAnimationManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); 12 | void js_cocos2dx_builder_CCBAnimationManager_finalize(JSContext *cx, JSObject *obj); 13 | void js_register_cocos2dx_builder_CCBAnimationManager(JSContext *cx, JS::HandleObject global); 14 | void register_all_cocos2dx_builder(JSContext* cx, JS::HandleObject obj); 15 | bool js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode(JSContext *cx, uint32_t argc, jsval *vp); 16 | bool js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId(JSContext *cx, uint32_t argc, jsval *vp); 17 | bool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames(JSContext *cx, uint32_t argc, jsval *vp); 18 | bool js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel(JSContext *cx, uint32_t argc, jsval *vp); 19 | bool js_cocos2dx_builder_CCBAnimationManager_setBaseValue(JSContext *cx, uint32_t argc, jsval *vp); 20 | bool js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes(JSContext *cx, uint32_t argc, jsval *vp); 21 | bool js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName(JSContext *cx, uint32_t argc, jsval *vp); 22 | bool js_cocos2dx_builder_CCBAnimationManager_setRootNode(JSContext *cx, uint32_t argc, jsval *vp); 23 | bool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration(JSContext *cx, uint32_t argc, jsval *vp); 24 | bool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName(JSContext *cx, uint32_t argc, jsval *vp); 25 | bool js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize(JSContext *cx, uint32_t argc, jsval *vp); 26 | bool js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName(JSContext *cx, uint32_t argc, jsval *vp); 27 | bool js_cocos2dx_builder_CCBAnimationManager_setObject(JSContext *cx, uint32_t argc, jsval *vp); 28 | bool js_cocos2dx_builder_CCBAnimationManager_getContainerSize(JSContext *cx, uint32_t argc, jsval *vp); 29 | bool js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel(JSContext *cx, uint32_t argc, jsval *vp); 30 | bool js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames(JSContext *cx, uint32_t argc, jsval *vp); 31 | bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); 32 | bool js_cocos2dx_builder_CCBAnimationManager_init(JSContext *cx, uint32_t argc, jsval *vp); 33 | bool js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks(JSContext *cx, uint32_t argc, jsval *vp); 34 | bool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); 35 | bool js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize(JSContext *cx, uint32_t argc, jsval *vp); 36 | bool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration(JSContext *cx, uint32_t argc, jsval *vp); 37 | bool js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName(JSContext *cx, uint32_t argc, jsval *vp); 38 | bool js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId(JSContext *cx, uint32_t argc, jsval *vp); 39 | bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName(JSContext *cx, uint32_t argc, jsval *vp); 40 | bool js_cocos2dx_builder_CCBAnimationManager_getRootNode(JSContext *cx, uint32_t argc, jsval *vp); 41 | bool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode(JSContext *cx, uint32_t argc, jsval *vp); 42 | bool js_cocos2dx_builder_CCBAnimationManager_setDelegate(JSContext *cx, uint32_t argc, jsval *vp); 43 | bool js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration(JSContext *cx, uint32_t argc, jsval *vp); 44 | bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode(JSContext *cx, uint32_t argc, jsval *vp); 45 | bool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed(JSContext *cx, uint32_t argc, jsval *vp); 46 | bool js_cocos2dx_builder_CCBAnimationManager_getSequenceId(JSContext *cx, uint32_t argc, jsval *vp); 47 | bool js_cocos2dx_builder_CCBAnimationManager_setCallFunc(JSContext *cx, uint32_t argc, jsval *vp); 48 | bool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes(JSContext *cx, uint32_t argc, jsval *vp); 49 | bool js_cocos2dx_builder_CCBAnimationManager_setSequences(JSContext *cx, uint32_t argc, jsval *vp); 50 | bool js_cocos2dx_builder_CCBAnimationManager_debug(JSContext *cx, uint32_t argc, jsval *vp); 51 | bool js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName(JSContext *cx, uint32_t argc, jsval *vp); 52 | bool js_cocos2dx_builder_CCBAnimationManager_CCBAnimationManager(JSContext *cx, uint32_t argc, jsval *vp); 53 | 54 | extern JSClass *jsb_cocosbuilder_CCBReader_class; 55 | extern JSObject *jsb_cocosbuilder_CCBReader_prototype; 56 | 57 | bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsval *vp); 58 | void js_cocos2dx_builder_CCBReader_finalize(JSContext *cx, JSObject *obj); 59 | void js_register_cocos2dx_builder_CCBReader(JSContext *cx, JS::HandleObject global); 60 | void register_all_cocos2dx_builder(JSContext* cx, JS::HandleObject obj); 61 | bool js_cocos2dx_builder_CCBReader_getAnimationManager(JSContext *cx, uint32_t argc, jsval *vp); 62 | bool js_cocos2dx_builder_CCBReader_setAnimationManager(JSContext *cx, uint32_t argc, jsval *vp); 63 | bool js_cocos2dx_builder_CCBReader_addOwnerOutletName(JSContext *cx, uint32_t argc, jsval *vp); 64 | bool js_cocos2dx_builder_CCBReader_getOwnerCallbackNames(JSContext *cx, uint32_t argc, jsval *vp); 65 | bool js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); 66 | bool js_cocos2dx_builder_CCBReader_setCCBRootPath(JSContext *cx, uint32_t argc, jsval *vp); 67 | bool js_cocos2dx_builder_CCBReader_addOwnerOutletNode(JSContext *cx, uint32_t argc, jsval *vp); 68 | bool js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes(JSContext *cx, uint32_t argc, jsval *vp); 69 | bool js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq(JSContext *cx, uint32_t argc, jsval *vp); 70 | bool js_cocos2dx_builder_CCBReader_getCCBRootPath(JSContext *cx, uint32_t argc, jsval *vp); 71 | bool js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); 72 | bool js_cocos2dx_builder_CCBReader_getOwnerOutletNodes(JSContext *cx, uint32_t argc, jsval *vp); 73 | bool js_cocos2dx_builder_CCBReader_readUTF8(JSContext *cx, uint32_t argc, jsval *vp); 74 | bool js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); 75 | bool js_cocos2dx_builder_CCBReader_getOwnerOutletNames(JSContext *cx, uint32_t argc, jsval *vp); 76 | bool js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq(JSContext *cx, uint32_t argc, jsval *vp); 77 | bool js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes(JSContext *cx, uint32_t argc, jsval *vp); 78 | bool js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers(JSContext *cx, uint32_t argc, jsval *vp); 79 | bool js_cocos2dx_builder_CCBReader_setResolutionScale(JSContext *cx, uint32_t argc, jsval *vp); 80 | bool js_cocos2dx_builder_CCBReader_CCBReader(JSContext *cx, uint32_t argc, jsval *vp); 81 | #endif 82 | 83 | --------------------------------------------------------------------------------