├── .gitignore ├── AUTHORS ├── CHANGELOG ├── LICENSE.txt ├── README.md ├── configs ├── CocosBuilderReader │ ├── CocosBuilderReader-complement.txt │ ├── CocosBuilderReader.bridgesupport │ ├── CocosBuilderReader_jsb.ini │ ├── gen_CocosBuilderReader_bridgesupport.sh │ └── gen_CocosBuilderReader_complement.sh ├── CocosDenshion │ ├── CocosDenshion-complement.txt │ ├── CocosDenshion.bridgesupport │ ├── CocosDenshion_jsb.ini │ ├── gen_CocosDenshion_bridgesupport.sh │ └── gen_CocosDenshion_complement.sh ├── chipmunk │ ├── chipmunk.bridgesupport │ ├── chipmunk_jsb.ini │ └── gen_chipmunk_bridgesupport.sh ├── cocos2d │ ├── cocos2d-complement.txt │ ├── cocos2d-ios-complement-exceptions.txt │ ├── cocos2d-ios-complement.txt │ ├── cocos2d-ios-exceptions.bridgesupport │ ├── cocos2d-ios.bridgesupport │ ├── cocos2d-mac-complement-exceptions.txt │ ├── cocos2d-mac-complement.txt │ ├── cocos2d-mac.bridgesupport │ ├── cocos2d.bridgesupport │ ├── cocos2d_jsb.ini │ ├── gen_cocos2d_bridgesupport.sh │ └── gen_cocos2d_complement.sh ├── opengl │ ├── opengl_jsb.ini │ ├── opengles20.bridgesupport │ └── webgl.idl └── system │ ├── gen_system_bridgesupport.sh │ ├── system.bridgesupport │ └── system_jsb.ini ├── docs ├── jsb.graffle ├── jsb_callbacks.png ├── jsb_calls.png ├── jsb_files.png ├── jsb_instance_call.png ├── jsb_intro.png └── jsb_new_class.png ├── generate_complement.py ├── generate_jsb.py ├── plugin_jsb_chipmunk.py ├── plugin_jsb_cocos2d.py ├── plugin_jsb_gl.py └── src ├── auto ├── jsb_CocosBuilderReader_classes.h ├── jsb_CocosBuilderReader_classes.mm ├── jsb_CocosBuilderReader_classes_registration.h ├── jsb_CocosDenshion_classes.h ├── jsb_CocosDenshion_classes.mm ├── jsb_CocosDenshion_classes_registration.h ├── jsb_CocosDenshion_functions.h ├── jsb_CocosDenshion_functions.mm ├── jsb_CocosDenshion_functions_registration.h ├── jsb_chipmunk_auto_classes.h ├── jsb_chipmunk_auto_classes.mm ├── jsb_chipmunk_auto_classes_registration.h ├── jsb_chipmunk_functions.h ├── jsb_chipmunk_functions.mm ├── jsb_chipmunk_functions_registration.h ├── jsb_cocos2d_classes.h ├── jsb_cocos2d_classes.mm ├── jsb_cocos2d_classes_registration.h ├── jsb_cocos2d_functions.h ├── jsb_cocos2d_functions.mm ├── jsb_cocos2d_functions_registration.h ├── jsb_cocos2d_ios_classes.h ├── jsb_cocos2d_ios_classes.mm ├── jsb_cocos2d_ios_classes_registration.h ├── jsb_cocos2d_ios_functions.h ├── jsb_cocos2d_ios_functions.mm ├── jsb_cocos2d_ios_functions_registration.h ├── jsb_cocos2d_mac_classes.h ├── jsb_cocos2d_mac_classes.mm ├── jsb_cocos2d_mac_classes_registration.h ├── jsb_cocos2d_mac_functions.h ├── jsb_cocos2d_mac_functions.mm ├── jsb_cocos2d_mac_functions_registration.h ├── jsb_opengl_functions.h ├── jsb_opengl_functions.mm ├── jsb_opengl_functions_registration.h ├── jsb_system_functions.h ├── jsb_system_functions.mm └── jsb_system_functions_registration.h ├── js ├── jsb.js ├── jsb_chipmunk.js ├── jsb_chipmunk_constants.js ├── jsb_cocos2d.js ├── jsb_cocos2d_constants.js ├── jsb_cocosbuilder.js ├── jsb_debugger.js ├── jsb_opengl.js ├── jsb_opengl_constants.js ├── jsb_sys.js └── main.example.js └── manual ├── jsb_CocosBuilderReader_manual.mm ├── jsb_NS_manual.h ├── jsb_NS_manual.mm ├── jsb_basic_conversions.h ├── jsb_basic_conversions.mm ├── jsb_chipmunk_manual.h ├── jsb_chipmunk_manual.mm ├── jsb_chipmunk_registration.h ├── jsb_chipmunk_registration.mm ├── jsb_cocos2d_manual.h ├── jsb_cocos2d_manual.mm ├── jsb_cocos2d_registration.h ├── jsb_cocos2d_registration.mm ├── jsb_config.h ├── jsb_core.h ├── jsb_core.mm ├── jsb_dbg.h ├── jsb_dbg.mm ├── jsb_opengl_manual.h ├── jsb_opengl_manual.mm ├── jsb_opengl_registration.h ├── jsb_opengl_registration.mm ├── jsb_system_registration.h └── jsb_system_registration.mm /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | *.pyc 17 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | JS Bindings authors 3 | ------------------- 4 | 5 | Lead Developer 6 | Ricardo Quesada (http://zynga.com) 7 | 8 | Contributors (alphabetically ordered): 9 | 10 | * Marcantonio m (https://plus.google.com/u/0/101339590535528286353/) 11 | Generators supports int64_t types 12 | 13 | * Mario Adrian (http://ma-source.de/): 14 | Fixed rounding error in JSB_jsval_from_NSNumber 15 | JSB_jsval_to_NSSet uses a real NSSet 16 | In JSB_jsval_to_NSDictionary the key can be a number or a string 17 | JSB_jsval_to_unknown: if a jsvalue is null, it returns [NSNull null] 18 | 19 | * Rolando Abarca (https://github.com/funkaster): 20 | Original author of remote debugging code 21 | 22 | * Sam Gross (https://github.com/colesbury): 23 | Fixed error when class has callbacks but no manual methods 24 | jsval to NSArray converts objects to the correct type 25 | Added JSB_jsval_to_unknown() 26 | Added JSB_jsval_to_struct() 27 | Added JSB_jsval_to_NSDictionary 28 | Simplified generate_jsb code by calling JSB_jsval_to directly 29 | Added error checking when callbacks returns a value 30 | Generator generates bindings from_Dictionary 31 | Generator does not crash if informal_protocols are not present 32 | "this" and "function" are rooted when calling an scheduled funciton, and unrooted when the block dies 33 | Unified conversions between callbacks retvals and retvals 34 | Simplified code when parsing structs 35 | Fixed JSB_jsval_from_NSString: works with Latin chars, not UTF8 chars 36 | 37 | * Sean Lin (http://www.cocos2d-html5.org): 38 | Added cc.Loader compatibility with cocos2d-html5 39 | 40 | * Sergej Tatarincev (https://github.com/SevInf) 41 | Added conversion for NSNull 42 | 43 | * Surith Thekkiam (https://github.com/folecr) 44 | Added JSON responses to debugger 45 | Fixed crashes on the debugger 46 | Added 'clean' command on the debugger 47 | 48 | * Wu-Hao (https://github.com/Wu-Hao) 49 | Added missing properties for the Chipmunk JS Bindings 50 | 51 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | version 0.9 - 31-Oct-2013 2 | - [FIX] JSB native code: 3 | all: Supports SpiderMonkey v25 API 4 | - [NEW] JSB Generator: 5 | generates SpiderMoneky v25 compatible code 6 | Supports int64_t types 7 | 8 | version 0.8 - 17-Jun-2013 9 | - [FIX] JSB native code: 10 | common: JSB_jsval_from_NSString expects Latin chars, not UTF8 chars 11 | cocos2d: "flipped" transitions support 3 arguments as expected 12 | 13 | version 0.7 - 1-May-2013 14 | - [NEW] Added support for encoded JS files (.jsc): 15 | You can bundle .jsc files (instead of .js) in your application in order to project your IP. 16 | Added option to autogenerate .jsc files on the fly (disabled by default) 17 | - [NEW] JSB Generator: generates "ctor" methods for Obj-C classes. 18 | - [FIX] JSB native code: 19 | cocos2d: CCLabel#string -> CCLabel#getString 20 | common: Fixed rounding error in JSB_jsval_from_NSNumber 21 | common: JSB_jsval_to_NSSet uses a real NSSet 22 | common: In JSB_jsval_to_NSDictionary the key can be a number or a string 23 | common: JSB_jsval_to_unknown: if a jsvalue is null, it returns [NSNull null] 24 | dbg: Debugger works with SpiderMonkey v20 25 | dbg: Debugger supports JSON responses 26 | - [FIX] JSB cocos2d: 27 | CCReuseGrid and CCStopGrid are bound 28 | 29 | version 0.6 - 20-Mar-2013 30 | - [NEW] Files: renamed js_bindigns_ to jsb_ 31 | - [NEW] JSB JS code: 32 | Added cocos2d and OpenGL constants (automatically created) 33 | Added cc.Loader. Compatible with cocos2d-html5 34 | - [NEW] JSB native code: 35 | common: New Naming Convention: 36 | XXX_to_jsval -> JSB_jsval_from_XXX 37 | jsval_to_XXX -> JSB_jsval_to_XXX 38 | All JSB functions start with "JSB_" 39 | common: jsval_to_NSDictionary is supported 40 | - [NEW] JSB Generator: Added support for plugins. Very easy to customize parsing of 3rd party library 41 | - [NEW] SpiderMonkey 19 Compatibility 42 | JS_PROP_SHAREABLE: it no longer used 43 | Since JS_CompileUTF8File() is no longer available, the scripts are executed using the JS C++ API 44 | Since JS_SetCStringsAreUTF8() is no longer available, the strings are converted using unichars 45 | TypedArray Functions no longer uses a context as parameter 46 | - [NEW] WebGL / OpenGL ES 2.0: basic functionality added 47 | - [FIX] JSB JS code: 48 | cc.base no longer used. Not compatible with SpiderMonkey 19 49 | - [FIX] JSB native code: 50 | chipmunk: addCollitionHandler: space is used as hash key too, preventing possible crashes with the GC 51 | cocos2d: RGBAProtocol: color/opacity -> getColor/getOpacity 52 | cocos2d:CCRotate(.*) XY is bound 53 | coocos2d: "this" and "function" are rooted when calling an scheduled funciton, and unrooted when the block dies 54 | common: jsval to NSArray converts inner objects too 55 | common: Checks return error in callbacks (only bool for the moment) 56 | common: jsval_from_NSDictionary works as expected 57 | - [FIX] JSB Generator: Fixed error when class has callbacks but no manual methods 58 | Simplified code. JSB_jsval_to is called directly. No need to add functions for that 59 | Generator generates bindings for jsval_from_nsdictionary 60 | Generator does not crash if informal_protocols are not present 61 | Unified conversions between callbacks retvals and retvals 62 | Simplified code when parsing structs 63 | 64 | version 0.5 - 29-Jan-2013 65 | - [FIX] JSB: Errors inside require() are reported correctly 66 | Improved errors in Chipmunk and cocos2d manual functions 67 | Removed JSB_PRECONDITION3(). Merged in JSB_PRECONDITION2() 68 | ParticleBatchNode is bound with the official API, like SpriteBatchNode 69 | cc.DrawNode.drawPoly works. 70 | JSB_jsval_to_NSObject returns NSNull if jsval is null 71 | 72 | version 0.4 - 4-Dec-2012 73 | - [FIX] JSB Chipmunk: Added missing properties 74 | The collision callback handlers are rooted/unrooted. Prevents posible crash 75 | body.setUserData()/getUserData() were removed. Instead use body.userData 76 | - [FIX] JSB CocosBuilder: Uses new API 77 | - [FIX] JSBCore: Added conversion for NSNull to JS 78 | 79 | version 0.3 - 7-Nov-2012 80 | - [NEW] Chipmunk bindings: Added Object Oriented JS API 81 | - JSB Chipmunk API is compatible with Chipmunk-JS API 82 | - Added missing functions to bindings: 83 | - cpAreaForPoly, cpCentroidForPoly, cpMomentForPoly, cpPolysShapeNew 84 | - [NEW] JSBCore: registration code for chipmunk/cocos2d moved to its own files 85 | Better macros to report errors: JSB_PRECONDITION2() & JSB_PRECONDITION2() 86 | Possibility to generate files compatible with cpp 87 | Added support for NSDictionary to jsval 88 | Converts recusive data-structures to jsval 89 | - [NEW] Script: jsb generates Object Oriented JS code for C-like API 90 | - [NEW] SpiderMonkey: Supports SpiderMonkey v16.0 API 91 | - [FIX] Callbacks: (Native-to-JS) if callback returns value, it is returned to native, as long it is a BOOL. 92 | - [FIX] Callbacks: (JS-Native-JS): 'this' is an optional parameter, and comes after the callback function 93 | - [FIX] Conversions: longlong and 64-bit long are represented by strings (and not an array of two elements) 94 | - [FIX] Xcode: Fixed all compiler warnings 95 | 96 | version 0.2 - XX-Sept-2012 97 | - [FIX] config file: only include cocos2d ios on iOS and cocos2d osx on OS X 98 | 99 | version 0.1 - 21-Ago-2012 100 | - [NEW] Initial public release 101 | - [NEW] bindings: 102 | - Added bindings for cocos2d-iphone v2.1 103 | - Added bindings for Chipmunk v6.1.1 104 | - Added bindings for CocosBuilder Reader 105 | - Added bindings for CocosDenshion 106 | 107 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | JS Bindings: http://github.com/zynga/jsbindings 2 | 3 | Copyright (c) 2012 - Zynga Inc. and contributors 4 | (see each file to see the different copyright owners) 5 | 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /configs/CocosBuilderReader/CocosBuilderReader-complement.txt: -------------------------------------------------------------------------------- 1 | {'CCBAnimationManager': {'protocols': [], 'subclass': 'NSObject', 'properties': {'documentCallbackNodes': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'rootContainerSize': ['nonatomic,assign', 'CGSizeNoneNoneNone'], 'autoPlaySequenceId': ['nonatomic,assign', 'intNoneNoneNone'], 'documentCallbackNames': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'documentControllerName': ['nonatomic,copy', 'NSStringNoneNone*'], 'keyframeCallbacks': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'documentOutletNames': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'documentOutletNodes': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'jsControlled': ['nonatomic,assign', 'BOOLNoneNoneNone'], 'rootNode': ['nonatomic,assign', 'CCNodeNoneNone*'], 'delegate': ['nonatomic,retain', 'NSObjectNone*'], 'sequences': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'owner': ['nonatomic,assign', 'idNoneNoneNone'], 'runningSequenceName': ['nonatomic,readonly', 'NSStringNoneNone*'], 'lastCompletedSequenceName': ['nonatomic,readonly', 'NSStringNoneNone*']}}, 'CCBRotateTo': {'protocols': ['NSCopying'], 'subclass': 'CCActionInterval'}, 'CCBSoundEffect': {'protocols': [], 'subclass': 'CCActionInstant'}, 'CCBReader': {'protocols': [], 'subclass': 'NSObject', 'properties': {'ownerCallbackNames': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'actionManager': ['nonatomic,retain', 'CCBAnimationManagerNoneNone*'], 'ownerOutletNodes': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'animationManagersForNodes': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'ownerCallbackNodes': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'nodesWithAnimationManagers': ['nonatomic,readonly', 'NSMutableArrayNoneNone*'], 'ownerOutletNames': ['nonatomic,readonly', 'NSMutableArrayNoneNone*']}}, 'CCBKeyframe': {'protocols': [], 'subclass': 'NSObject', 'properties': {'easingOpt': ['nonatomic,assign', 'floatNoneNoneNone'], 'easingType': ['nonatomic,assign', 'intNoneNoneNone'], 'value': ['nonatomic,retain', 'idNoneNoneNone'], 'time': ['nonatomic,assign', 'floatNoneNoneNone']}}, 'CCBSetSpriteFrame': {'protocols': ['NSCopying'], 'subclass': 'CCActionInstant'}, 'CCBSequence': {'protocols': [], 'subclass': 'NSObject', 'properties': {'sequenceId': ['nonatomic,assign', 'intNoneNoneNone'], 'name': ['nonatomic,copy', 'NSStringNoneNone*'], 'soundChannel': ['nonatomic,retain', 'CCBSequencePropertyNoneNone*'], 'callbackChannel': ['nonatomic,retain', 'CCBSequencePropertyNoneNone*'], 'duration': ['nonatomic,assign', 'floatNoneNoneNone'], 'chainedSequenceId': ['nonatomic,assign', 'intNoneNoneNone']}}, 'CCBAnimationManagerDelegate': {'protocols': ['NSObject']}, 'CCEaseInstant': {'protocols': ['NSCopying'], 'subclass': 'CCActionEase'}, 'CCBSequenceProperty': {'protocols': [], 'subclass': 'NSObject', 'properties': {'type': ['nonatomic,assign', 'intNoneNoneNone'], 'name': ['nonatomic,retain', 'NSStringNoneNone*'], 'keyframes': ['nonatomic,readonly', 'NSMutableArrayNoneNone*']}}} -------------------------------------------------------------------------------- /configs/CocosBuilderReader/CocosBuilderReader_jsb.ini: -------------------------------------------------------------------------------- 1 | [CocosBuilderReader] 2 | 3 | # You can extend the functionality by using plugins 4 | # Basically you can override the functionality of the converters 5 | ## Ignore constants for CocosBuilderReader 6 | plugin = constant_class = JSBGenerateConstants_Ignore, 7 | 8 | # JS namespace. By default it is the same as config file namespace. 9 | # This namespace is used then the script autogenerates JS code. eg: with the constants 10 | ## Not used in CCB Reader 11 | js_namespace = cc 12 | 13 | # prefix that will be removed from the ObjC classes in order to generate the JS classes 14 | # eg: If the class name is CCNode, then on JavaScript it will be Node 15 | obj_class_prefix_to_remove = CCB 16 | 17 | # Classes to generate. Use '*' to generate all the parsed classes. 18 | # Subclasses will be parsed as well. 19 | # eg: If CCSprite is parsed, then CCNode and NSObject will be parsed as well 20 | # It supports regular expressions to match class names. 21 | # eg: all cocos2d actions ending in 'By': CC(.*)By 22 | classes_to_parse = CCBReader, CCBAnimationManager 23 | 24 | # Classes to ignore. 25 | # It is a good idea to add classes that you don't want to have a proxy object. Usually internal classes, 26 | # or classes that are already native on JavaScript should be added here. 27 | # It supports regular expressions to match class names. 28 | # eg: all NS classes: NS(.*) 29 | classes_to_ignore = NS(.*) 30 | 31 | # Class properties 32 | # Options 33 | # manual Means that the class is manually bound. No binding info will generated, but it can be used. 34 | class_properties = NSObject = manual, 35 | CCNode = manual, 36 | CCScene = manual, 37 | CCBReader = name:"_Reader", 38 | CCBAnimationManager = reserved_slots:2, 39 | CCCallBlockN = manual, 40 | 41 | # Whether or not to generate constructors from base classes for the current class. 42 | # In JavaScript, the "constructors" or "static methods" are not "inherited". 43 | # It is recommended to set it to "auto". 44 | # Options: 45 | # False: Don't inherited 46 | # True: Inherit all class methods from all ancestors 47 | # Auto: Inherit only if it has no class constructors. Stop when the fist class constructor is added. 48 | inherit_class_methods = Auto 49 | 50 | # Files that are going to be imported by the autogenerated files. 51 | # Useful to declare subclasses of an already bound project 52 | # eg: manual bindings for NSObject 53 | import_files = jsb_NS_manual.h, 54 | CCBReader.h, 55 | CCBAnimationManager.h 56 | 57 | # The prefix will be removed from function name. 58 | # eg: if the C function is "cpBodyAddShape", then the JS name will be "bodyWithAddShape" 59 | ## For cocos2d add "cc" 60 | function_prefix_to_remove = 61 | 62 | # Free functions to be parsed 63 | functions_to_parse = 64 | # Free functions not to parse 65 | functions_to_ignore = 66 | 67 | # Rules used for methods: 68 | # options: 69 | # name:"js_name" Rename methods. 70 | # ignore This method will be ignored. 71 | # callback This method is a callback. It will be invoked from Objective-C 72 | # no_swizzle It means that the callback function is an optional protocol and should not be "swizzled" because there is no implementation for it. 73 | # variadic_2_array It means that all arguments are variadic, and an Array will be created with them 74 | # merge:name | name... List of methods names that should be merged with this method as well. 75 | # manual It means that its implementation won't be autogenerated. It is implemented manually 76 | # 77 | # Regular expressions are supported in the Class names, but not in the Method names 78 | # 79 | method_properties = CCBReader # nodeGraphFromFile:owner:parentSize: = name:"load"; merge:"nodeGraphFromFile:"|"nodeGraphFromFile:owner:", 80 | CCBReader # sceneWithNodeGraphFromFile:owner:parentSize: = name:"loadScene"; merge:"sceneWithNodeGraphFromFile:"|"sceneWithNodeGraphFromFile:owner:", 81 | CCBReader#reader = name:"create", 82 | CCBAnimationManager#setCompletedAnimationCallbackBlock: = name:"setCompletedAnimationCallback";manual, 83 | 84 | # 85 | # Struct properties 86 | # options: 87 | # opaque The structure will be treated as 'opaque' and can't not be inspected from JS. 88 | # Opaque structures are much faster to generate than 'manual' or 'automatic' structures 89 | # manual Manual conversion is provided for this structures. jsval_to_structname() and structname_to_jsval shall exists in your project 90 | struct_properties = CGPoint = manual, 91 | CGSize = manual, 92 | CGRect = manual, 93 | 94 | # BridgeSupport files 95 | # add as many as you need. Usually you will only one. 96 | bridge_support_file = CocosBuilderReader.bridgesupport 97 | 98 | # File that contains information that complements BridgeSupport (not present on BridgeSupport file) 99 | complement_file = CocosBuilderReader-complement.txt 100 | -------------------------------------------------------------------------------- /configs/CocosBuilderReader/gen_CocosBuilderReader_bridgesupport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # run this script from the cocosBuilderReader directory. eg: 4 | # cd ~/src/cocos2d-iphone/externals/CocosBuilderReader/ 5 | # 6 | gen_bridge_metadata -F complete --no-64-bit -c '-DNDEBUG -I. -I../../../cocos2d/.' *.h ../../../cocos2d/CCScene.h -o ../../../external/JavaScript/jsbindings/configs/CocosBuilderReader/CocosBuilderReader.bridgesupport 7 | -------------------------------------------------------------------------------- /configs/CocosBuilderReader/gen_CocosBuilderReader_complement.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # run this script from the cocosBuilderReader directory. eg: 4 | # cd ~/src/cocos2d-iphone/externals/CocosBuilderReader/ 5 | # 6 | ../../../external/JavaScript/jsbindings/generate_complement.py -o ../../../external/JavaScript/jsbindings/configs/CocosBuilderReader/CocosBuilderReader-complement.txt *.h 7 | 8 | -------------------------------------------------------------------------------- /configs/CocosDenshion/CocosDenshion-complement.txt: -------------------------------------------------------------------------------- 1 | {'CDSoundSourcePitchBender': {'protocols': [], 'subclass': 'CDPropertyModifier'}, 'CDBufferLoadRequest': {'protocols': [], 'subclass': 'NSObject', 'properties': {'soundId': ['readonly', 'intNoneNoneNone'], 'filePath': ['readonly', 'NSStringNoneNone*']}}, 'CDLongAudioSource': {'protocols': ['AVAudioPlayerDelegate', 'CDAudioInterruptProtocol'], 'subclass': 'NSObject', 'properties': {'audioSourcePlayer': ['readonly', 'AVAudioPlayerNoneNone*'], 'volume': ['readwrite, nonatomic', 'floatNoneNoneNone'], 'numberOfLoops': ['readwrite, nonatomic', 'NSIntegerNoneNoneNone'], 'audioSourceFilePath': ['readonly', 'NSStringNoneNone*'], 'backgroundMusic': ['readwrite, nonatomic', 'BOOLNoneNoneNone'], 'delegate': ['assign', 'idNoneNone']}}, 'CDSoundEngineFader': {'protocols': [], 'subclass': 'CDPropertyModifier'}, 'SimpleAudioEngine': {'protocols': ['CDAudioInterruptProtocol'], 'subclass': 'NSObject', 'properties': {'willPlayBackgroundMusic': ['readonly', 'BOOLNoneNoneNone'], 'effectsVolume': ['readwrite', 'floatNoneNoneNone'], 'backgroundMusicVolume': ['readwrite', 'floatNoneNoneNone']}}, 'CDSoundSource': {'protocols': ['CDAudioTransportProtocol', 'CDAudioInterruptProtocol'], 'subclass': 'NSObject', 'properties': {'lastError': ['readonly', 'ALenumNoneNoneNone'], 'looping': ['readwrite, nonatomic', 'BOOLNoneNoneNone'], 'soundId': ['readwrite, nonatomic', 'intNoneNoneNone'], 'gain': ['readwrite, nonatomic', 'floatNoneNoneNone'], 'pitch': ['readwrite, nonatomic', 'floatNoneNoneNone'], 'isPlaying': ['readonly', 'BOOLNoneNoneNone'], 'pan': ['readwrite, nonatomic', 'floatNoneNoneNone'], 'durationInSeconds': ['readonly', 'floatNoneNoneNone']}}, 'CDSoundSourceFader': {'protocols': [], 'subclass': 'CDPropertyModifier'}, 'CDUtilities': {'protocols': [], 'subclass': 'NSObject'}, 'CDSoundSourcePanner': {'protocols': [], 'subclass': 'CDPropertyModifier'}, 'CDBufferManager': {'protocols': [], 'subclass': 'NSObject'}, 'CDAsynchBufferLoader': {'protocols': [], 'subclass': 'NSOperation'}, 'CDSoundEngine': {'protocols': ['CDAudioInterruptProtocol'], 'subclass': 'NSObject', 'properties': {'sourceTotal': ['readonly', 'intNoneNoneNone'], 'sourceGroupTotal': ['readonly', 'NSUIntegerNoneNoneNone'], 'asynchLoadProgress': ['readwrite', 'floatNoneNoneNone'], 'lastErrorCode': ['readonly', 'ALenumNoneNoneNone'], 'getGainWorks': ['readonly', 'BOOLNoneNoneNone'], 'masterGain': ['readwrite, nonatomic', 'ALfloatNoneNoneNone'], 'functioning': ['readonly', 'BOOLNoneNoneNone']}}, 'CDAudioManager': {'protocols': ['CDLongAudioSourceDelegate', 'CDAudioInterruptProtocol', 'AVAudioSessionDelegate'], 'subclass': 'NSObject', 'properties': {'soundEngine': ['readonly', 'CDSoundEngineNoneNone*'], 'willPlayBackgroundMusic': ['readonly', 'BOOLNoneNoneNone'], 'backgroundMusic': ['readonly', 'CDLongAudioSourceNoneNone*']}}, 'CDFloatInterpolator': {'protocols': [], 'subclass': 'NSObject', 'properties': {'start': ['readwrite, nonatomic', 'floatNoneNoneNone'], 'interpolationType': ['readwrite, nonatomic', 'tCDInterpolationTypeNoneNoneNone'], 'end': ['readwrite, nonatomic', 'floatNoneNoneNone']}}, 'CDLongAudioSourceFader': {'protocols': [], 'subclass': 'CDPropertyModifier'}, 'CDPropertyModifier': {'protocols': [], 'subclass': 'NSObject', 'properties': {'stopTargetWhenComplete': ['readwrite, nonatomic', 'BOOLNoneNoneNone'], 'interpolationType': ['readwrite, nonatomic', 'tCDInterpolationTypeNoneNoneNone'], 'startValue': ['readwrite, nonatomic', 'floatNoneNoneNone'], 'endValue': ['readwrite, nonatomic', 'floatNoneNoneNone']}}, 'CDAsynchInitialiser': {'protocols': [], 'subclass': 'NSOperation'}, 'CDAudioInterruptTargetGroup': {'protocols': ['CDAudioInterruptProtocol'], 'subclass': 'NSObject'}} -------------------------------------------------------------------------------- /configs/CocosDenshion/CocosDenshion_jsb.ini: -------------------------------------------------------------------------------- 1 | [CocosDenshion] 2 | 3 | # You can extend the functionality by using plugins 4 | # Basically you can override the functionality of the converters 5 | ## Ignore constants for CocosDenshion 6 | plugin = constant_class = JSBGenerateConstants_Ignore, 7 | 8 | # JS namespace. By default it is the same as config file namespace. 9 | # This namespace is used then the script autogenerates JS code. eg: with the constants 10 | ## Not used in CocosDenshion 11 | js_namespace = cc 12 | 13 | # prefix that will be removed from the ObjC classes in order to generate the JS classes 14 | # ex: If the class name is CCNode, then on JavaScript it will be Node 15 | ## CocosDenshion classes start with 'CD' 16 | obj_class_prefix_to_remove = CD 17 | 18 | # Classes to generate. Use '*' to generate all the parsed classes. 19 | # Subclasses will be parsed as well. 20 | # ex: If CCSprite is parsed, then CCNode and NSObject will be parsed as well 21 | # It supports regular expressions to match class names. 22 | # eg: all cocos2d actions ending in 'By': CC(.*)By 23 | ## Only parse 'SimpleAudioEngine' 24 | classes_to_parse = SimpleAudioEngine 25 | 26 | # Classes to ignore. 27 | # It is a good idea to add classes that you don't want to have a proxy object. Usually internal classes, 28 | # or classes that are already native on JavaScript should be added here. 29 | # It supports regular expressions to match class names. 30 | # eg: all NS classes: NS(.*) 31 | ## Ignore the rest of the classes 32 | classes_to_ignore = NS(.*), CDAsynchBufferLoader 33 | 34 | # Class properties 35 | # Options 36 | # manual Means that the class is manually bound. No binding info will generated, but it can be used. 37 | class_properties = NSObject = manual, 38 | NSEvent = manual, 39 | SimpleAudioEngine = name:"AudioEngine", 40 | 41 | # Whether or not to generate constructors from base classes for the current class. 42 | # In JavaScript, the "constructors" or "static methods" are not "inherited". 43 | # It is recommended to set it to "auto". 44 | # Options: 45 | # False: Don't inherited 46 | # True: Inherit all class methods from all ancestors 47 | # Auto: Inherit only if it has no class constructors. Stop when the fist class constructor is added. 48 | inherit_class_methods = Auto 49 | 50 | # Files that are going to be imported by the autogenerated files. 51 | # Useful to declare subclasses of an already bound project 52 | # eg: manual bindigns for NSObject 53 | import_files = jsb_NS_manual.h 54 | 55 | # The prefix will be removed from function name. 56 | # eg: if the C function is "cpBodyAddShape", then the JS name will be "bodyWithAddShape" 57 | ## For cocos2d add "cc" 58 | function_prefix_to_remove = cd 59 | 60 | # Free functions to be parsed 61 | functions_to_parse = cd(.*) 62 | # Free functions not to parse 63 | functions_to_ignore = ccArray*, ccCArray* 64 | 65 | # Rules used for methods: 66 | # options: 67 | # name:"js_name" Rename methods. 68 | # ignore This method will be ignored. 69 | # callback This method is a callback. It will be invoked from Objective-C 70 | # no_swizzle It means that the callback function is an optional protocol and should not be "swizzled" because there is no implementation for it. 71 | # variadic_2_array It means that all arguments are variadic, and an Array will be created with them 72 | # merge:name | name... List of methods names that should be merged with this method as well. 73 | # manual It means that its implementation won't be autogenerated. It is implemented manually 74 | # 75 | # Regular expressions are supported in the Class names, but not in the Method names 76 | # 77 | method_properties = SimpleAudioEngine # sharedEngine = name:"getInstance", 78 | SimpleAudioEngine # playEffect:pitch:pan:gain: = name:"playEffect"; merge:"playEffect:", 79 | SimpleAudioEngine # preloadBackgroundMusic: = name:"preloadMusic", 80 | SimpleAudioEngine # playBackgroundMusic:loop: = name:"playMusic"; merge:"playBackgroundMusic:", 81 | SimpleAudioEngine # stopBackgroundMusic = name:"stopMusic", 82 | SimpleAudioEngine # pauseBackgroundMusic = name:"pauseMusic", 83 | SimpleAudioEngine # resumeBackgroundMusic = name:"resumeMusic", 84 | SimpleAudioEngine # rewindBackgroundMusic = name:"rewindMusic", 85 | SimpleAudioEngine # isBackgroundMusicPlaying = name:"isMusicPlaying", 86 | SimpleAudioEngine # setBackgroundMusicVolume: = name:"setMusicVolume", 87 | SimpleAudioEngine # backgroundMusicVolume = name:"getMusicVolume", 88 | # 89 | # Struct properties 90 | # options: 91 | # opaque The structure will be treated as 'opaque' and can't not be inspected from JS. 92 | # Opaque structures are much faster to generate than 'manual' or 'automatic' structures 93 | # manual Manual conversion is provided for this structures. jsval_to_structname() and structname_to_jsval shall exists in your project 94 | struct_properties = 95 | 96 | # BridgeSupport files 97 | # add as many as you need. Usually you will only one. 98 | bridge_support_file = CocosDenshion.bridgesupport 99 | 100 | # File that contains information that complements BridgeSupport (not present on BridgeSupport file) 101 | complement_file = CocosDenshion-complement.txt 102 | -------------------------------------------------------------------------------- /configs/CocosDenshion/gen_CocosDenshion_bridgesupport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # run this script from the CocosDenshion directory. eg: 4 | # cd ~/src/cocos2d-iphone/CocosDenshion/CocosDenshion 5 | # 6 | gen_bridge_metadata -F complete --no-64-bit -c '-DNDEBUG -I.' *.h -o ../../external/JavaScript/jsbindings/configs/CocosDenshion/CocosDenshion.bridgesupport 7 | -------------------------------------------------------------------------------- /configs/CocosDenshion/gen_CocosDenshion_complement.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # run this script from the CocosDenshion directory. eg: 4 | # cd ~/src/cocos2d-iphone/CocosDenshion/CocosDenshion 5 | # 6 | ../../external/JavaScript/jsbindings/generate_complement.py -o ../../external/JavaScript/jsbindings/configs/CocosDenshion/CocosDenshion-complement.txt *.h 7 | 8 | -------------------------------------------------------------------------------- /configs/chipmunk/chipmunk_jsb.ini: -------------------------------------------------------------------------------- 1 | [chipmunk] 2 | 3 | # You can extend the functionality by using plugins 4 | # Basically you can override the functionality of the converters 5 | plugin = constant_class = plugin_jsb_chipmunk.JSBGenerateConstants_CP, 6 | 7 | # JS namespace. By default it is the same as config file namespace. 8 | # This namespace is used then the script autogenerates JS code. eg: with the constants 9 | js_namespace = cp 10 | 11 | # prefix that will be removed from the ObjC classes in order to generate the JS classes 12 | # ex: If the class name is CCNode, then on JavaScript it will be Node 13 | ## None, since chipmunk has no Objective-C classes 14 | obj_class_prefix_to_remove = 15 | 16 | # Classes to generate. Use '*' to generate all the parsed classes. 17 | # Subclasses will be parsed as well. 18 | # ex: If CCSprite is parsed, then CCNode and NSObject will be parsed as well 19 | # It supports regular expressions to match class names. 20 | # eg: all cocos2d actions ending in 'By': CC(.*)By 21 | ## None, since chipmunk has no Objective-C classes 22 | classes_to_parse = 23 | 24 | # Classes to ignore. 25 | # It is a good idea to add classes that you don't want to have a proxy object. Usually internal classes, 26 | # or classes that are already native on JavaScript should be added here. 27 | # It supports regular expressions to match class names. 28 | # eg: all NS classes: NS(.*) 29 | ## None, since chipmunk has no Objective-C classes 30 | classes_to_ignore = 31 | 32 | # Class properties 33 | # Options 34 | # manual Means that the class is manually bound. No binding info will generated, but it can be used. 35 | class_properties = 36 | 37 | # Whether or not to generate constructors from base classes for the current class. 38 | # In JavaScript, the "constructors" or "static methods" are not "inherited". 39 | # It is recommended to set it to "auto". 40 | # Options: 41 | # False: Don't inherited 42 | # True: Inherit all class methods from all ancestors 43 | # Auto: Inherit only if it has no class constructors. Stop when the fist class constructor is added. 44 | ## Ignored, since chipmunk has no classes 45 | inherit_class_methods = Auto 46 | 47 | # Method properties 48 | # options: 49 | # name:"js_name" Rename methods. 50 | # ignore This method will be ignored. 51 | # callback This method is a callback. It will be invoked from Objective-C 52 | # optional_args_since:2 It means that all arguments starting from the 2nd argument are optionals 53 | # variadic_2_array It means that all arguments are variadic, and an Array will be created with them 54 | ## None, since chipmunk has not methods 55 | method_properties = 56 | 57 | # Files that are going to be imported by the auto-generated files. 58 | # Useful to declare subclasses of an already bound project 59 | # eg: manual bindings for NSObject 60 | import_files = jsb_chipmunk_manual.h 61 | 62 | compatible_with_cpp = True 63 | 64 | # The prefix will be removed from function name. 65 | # eg: if the C function is "cpBodyAddShape", then the JS name will be "bodyWithAddShape" 66 | ## For chipmunk add "cp" 67 | function_prefix_to_remove = cp 68 | 69 | # Free functions to be parsed 70 | functions_to_parse = cp(.*) 71 | 72 | # Free functions not to parse 73 | ## Add here all chipmunk "private" and "unsafe" functions 74 | ## cpv is not wrapped because it uses a function in JS, which is faster 75 | functions_to_ignore = cpClosetPointOnSegment, cpSpaceActivateBody, cpSpaceLock, cpSpaceUnlock, cpSpaceFilterArbiters, cpSpaceArbiterSetFilter, cpSpaceGetPostStepData, 76 | cpSpacePushContacts, cpContactBufferGetArray, cpSpacePushFreshContactBuffer, cpSpaceProcessComponents, cpSpatialIndexInit, 77 | cpSpaceLookupHandler, cpSpaceUncacheArbiter, cpShapeActive, cpShapeUpdateFunc, cpSpaceCollideShapes,cpContactInit, cpArbiterInit, 78 | cpArbiterUnthread, cpArbiterUpdate, cpArbiterPreStep, cpArbiterApplyCachedImpulse, cpArbiterApplyImpulse, cpArbiterCallSeparate, 79 | cpArrayNew, cpArrayFree, cpArrayPush, cpArrayPop, cpArrayDeleteObj, cpArrayContains, cpArrayFreeEach, cpConstraintNext, 80 | cpArbiterNext, cpHashSetNew, cpHashSetSetDefaultValue, cpHashSetFree, cpHashSetCount, cpHashSetInsert, 81 | cpHashSetRemove, cpHashSetFind, cpHashSetEach, cpHashSetFilter, 82 | cpBodyAddShape, cpBodyRemoveShape, cpBodyRemoveConstraint, 83 | cpCircleShapeSetRadius, cpCircleShapeSetOffset, cpSegmentShapeSetEndpoints, cpSegmentShapeSetRadius, cpPolyShapeSetVerts, 84 | cpSpaceRemoveCollisionHandler, cpSpaceAddCollisionHandler, 85 | cpBody(.*)UserData, 86 | cp(.*)Alloc(.*), 87 | cpv, 88 | 89 | # 90 | # Struct properties 91 | # options: 92 | # opaque The structure will be treated as 'opaque' and can't not be inspected from JS. 93 | # Opaque structures are much faster to generate than 'manual' or 'automatic' structures 94 | # manual:[func] Manual conversion is provided for this structures. jsval_to_structname() and structname_to_jsval shall exists in your project 95 | # If "func" is passed, it will call that conversion function 96 | struct_properties = cpSpace = opaque, 97 | cpBody = opaque, 98 | cpShape = opaque, 99 | cpConstraint = opaque, 100 | cpArbiter = opaque, 101 | cpVect = manual, 102 | CGPoint = manual, 103 | CGSize = manual, 104 | CGRect = manual, 105 | cpCollisionType = manual:long, 106 | cpGroup = manual:long, 107 | cpBB = manual, 108 | 109 | # 110 | # Object oriented C library ? 111 | # If so, convert C-like API to object oriented API 112 | # This will generate JavaScript code that will call the C API in a Object Oriented manner. 113 | # The generated code might need to be manually modified 114 | # 115 | ## Chipmunk has an OO API. 116 | objects_from_c_functions = constructor_suffix = New, 117 | destructor_suffix = Free, 118 | classes = cpSpace; cpBody; 119 | cpShape; cpPolyShape:cpShape; cpSegmentShape:cpShape; cpCircleShape:cpShape; 120 | cpConstraint; cpDampedSpring:cpConstraint; cpDampedRotarySpring:cpConstraint; cpGearJoint:cpConstraint; cpGrooveJoint:cpConstraint; cpPinJoint:cpConstraint; cpPivotJoint:cpConstraint; cpRatchetJoint:cpConstraint; cpRotaryLimitJoint:cpConstraint; cpSimpleMotor:cpConstraint; cpSlideJoint:cpConstraint; cpArbiter, 121 | base_class = cpBase, 122 | manual_bound_methods = cpArbiterGetBodies; cpArbiterGetShapes; cpSpaceAddCollisionHandler; cpSpaceRemoveCollisionHandler; cpPolyShapeNew; cpBodyNew; cpSpaceFree; cpSpaceRemoveShape; cpSpaceRemoveConstraint; cpSpaceRemoveBody; cpSpaceRemoveStaticShape; cpSpaceAddShape; cpSpaceAddStaticShape; cpSpaceAddBody; cpSpaceAddConstraint, 123 | 124 | 125 | # BridgeSupport file 126 | bridge_support_file = ./chipmunk.bridgesupport 127 | 128 | # File that contains information that complements BridgeSupport (not present on BridgeSupport file) 129 | ## None, since chipmunk has no classes 130 | complement_file = 131 | -------------------------------------------------------------------------------- /configs/chipmunk/gen_chipmunk_bridgesupport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # run this script from chipmunk include directory 4 | # cd cocos2d-iphone/externals/Chipmunk/include/chipmunk 5 | # 6 | gen_bridge_metadata -F complete --no-64-bit -c '-DCP_ALLOW_PRIVATE_ACCESS=0 -DNDEBUG -I. -Iconstraints/.' *.h constraints/*.h -o ../../../../external/JavaScript/jsbindings/configs/chipmunk/chipmunk.bridgesupport 7 | -------------------------------------------------------------------------------- /configs/cocos2d/cocos2d-ios-complement-exceptions.txt: -------------------------------------------------------------------------------- 1 | { 2 | 'CCDirector': {'protocols': [], 'subclass': 'NSObject'}, 3 | 'CCGLView': {'protocols': [], 'subclass': 'NSObject'}, 4 | 'CCLayer': {'protocols': ['CCAccelerometerDelegate', 'CCTouchOneByOneDelegate', 'CCTouchAllAtOnceDelegate'], 'subclass': 'CCNode'} 5 | } 6 | -------------------------------------------------------------------------------- /configs/cocos2d/cocos2d-ios-exceptions.bridgesupport: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /configs/cocos2d/cocos2d-mac-complement-exceptions.txt: -------------------------------------------------------------------------------- 1 | { 2 | 'CCDirector': {'protocols': [], 'subclass': 'NSObject'}, 3 | 'CCLayer': {'protocols': ['CCKeyboardEventDelegate', 'CCMouseEventDelegate', 'CCTouchEventDelegate'], 'subclass': 'CCNode'} 4 | } 5 | -------------------------------------------------------------------------------- /configs/cocos2d/gen_cocos2d_bridgesupport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # run this script from the cocos2d directory 4 | # eg: $ cd ~/src/cocos2d-iphone/cocos2d/ 5 | # 6 | mv ccDeprecated.h ccDeprecated.xxx 7 | 8 | # cocos2d 9 | gen_bridge_metadata -F complete --no-64-bit -c '-DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -ISupport -IPlatforms -I. -I../external/Chipmunk/include/chipmunk/. -I../external/Chipmunk/include/chipmunk/constraints/.' *.h Support/*.h Platforms/*.h -o ../external/JavaScript/jsbindings/configs/cocos2d/cocos2d.bridgesupport 10 | 11 | # cocos2d-mac 12 | gen_bridge_metadata -F complete --64-bit -c '-D__CC_PLATFORM_MAC -ISupport -IPlatforms -IPlatforms/Mac -I.' *.h Platforms/*.h Platforms/Mac/*.h -o ../external/JavaScript/jsbindings/configs/cocos2d/cocos2d-mac.bridgesupport 13 | 14 | # cocos2d-ios 15 | gen_bridge_metadata -F complete --no-64-bit -c '-D__CC_PLATFORM_IOS -ISupport -IPlatforms -IPlatforms/iOS -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/.' *.h Platforms/*.h Platforms/iOS/*.h -o ../external/JavaScript/jsbindings/configs/cocos2d/cocos2d-ios.bridgesupport -e ../external/JavaScript/jsbindings/configs/cocos2d/cocos2d-ios-exceptions.bridgesupport 16 | 17 | mv ccDeprecated.xxx ccDeprecated.h 18 | -------------------------------------------------------------------------------- /configs/cocos2d/gen_cocos2d_complement.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # run this script from the cocos2d directory 4 | # eg: $ cd ~/src/cocos2d-iphone/cocos2d/ 5 | # 6 | mv ccDeprecated.h ccDeprecated.xxx 7 | 8 | # Common 9 | ../external/JavaScript/jsbindings/generate_complement.py -e ../external/JavaScript/jsbindings/configs/cocos2d/cocos2d-ios-complement-exceptions.txt -o ../external/JavaScript/jsbindings/configs/cocos2d/cocos2d-complement.txt *.h Support/*.h Platforms/*.h 10 | 11 | # iOS 12 | ../external/JavaScript/jsbindings/generate_complement.py -e ../external/JavaScript/jsbindings/configs/cocos2d/cocos2d-ios-complement-exceptions.txt -o ../external/JavaScript/jsbindings/configs/cocos2d/cocos2d-ios-complement.txt *.h Support/*.h Platforms/*.h Platforms/iOS/*.h 13 | 14 | # Mac 15 | ../external/JavaScript/jsbindings/generate_complement.py -e ../external/JavaScript/jsbindings/configs/cocos2d/cocos2d-mac-complement-exceptions.txt -o ../external/JavaScript/jsbindings/configs/cocos2d/cocos2d-mac-complement.txt *.h Support/*.h Platforms/*.h Platforms/Mac/*.h 16 | 17 | mv ccDeprecated.xxx ccDeprecated.h 18 | -------------------------------------------------------------------------------- /configs/opengl/opengl_jsb.ini: -------------------------------------------------------------------------------- 1 | [opengl] 2 | 3 | # You can extend the functionality by using plugins 4 | # Basically you can override the functionality of the converters 5 | plugin = function_class = plugin_jsb_gl.JSBGenerateFunctions_GL, 6 | 7 | # JS namespace. By default it is the same as config file namespace. 8 | # This namespace is used then the script autogenerates JS code. eg: with the constants 9 | js_namespace = gl 10 | 11 | # prefix that will be removed from the ObjC classes in order to generate the JS classes 12 | # ex: If the class name is CCNode, then on JavaScript it will be Node 13 | ## None, since OpenGL has no Objective-C classes 14 | obj_class_prefix_to_remove = 15 | 16 | # Classes to generate. Use '*' to generate all the parsed classes. 17 | # Subclasses will be parsed as well. 18 | # ex: If CCSprite is parsed, then CCNode and NSObject will be parsed as well 19 | # It supports regular expressions to match class names. 20 | # eg: all cocos2d actions ending in 'By': CC(.*)By 21 | ## None, since OpenGL has no Objective-C classes 22 | classes_to_parse = 23 | 24 | # Classes to ignore. 25 | # It is a good idea to add classes that you don't want to have a proxy object. Usually internal classes, 26 | # or classes that are already native on JavaScript should be added here. 27 | # It supports regular expressions to match class names. 28 | # eg: all NS classes: NS(.*) 29 | ## None, since OpenGL has no Objective-C classes 30 | classes_to_ignore = 31 | 32 | # Class properties 33 | # Options 34 | # manual Means that the class is manually bound. No binding info will generated, but it can be used. 35 | class_properties = 36 | 37 | # Whether or not to generate constructors from base classes for the current class. 38 | # In JavaScript, the "constructors" or "static methods" are not "inherited". 39 | # It is recommended to set it to "auto". 40 | # Options: 41 | # False: Don't inherited 42 | # True: Inherit all class methods from all ancestors 43 | # Auto: Inherit only if it has no class constructors. Stop when the fist class constructor is added. 44 | ## Ignored, since OpenGL has no classes 45 | inherit_class_methods = Auto 46 | 47 | # Method properties 48 | # options: 49 | # name:"js_name" Rename methods. 50 | # ignore This method will be ignored. 51 | # callback This method is a callback. It will be invoked from Objective-C 52 | # optional_args_since:2 It means that all arguments starting from the 2nd argument are optionals 53 | # variadic_2_array It means that all arguments are variadic, and an Array will be created with them 54 | ## None, since OpenGL ES has not methods 55 | method_properties = 56 | 57 | # Files that are going to be imported by the auto-generated files. 58 | # Useful to declare subclasses of an already bound project 59 | # eg: manual bindings for NSObject 60 | import_files = jsb_opengl_manual.h 61 | 62 | compatible_with_cpp = True 63 | 64 | # The prefix will be removed from function name. 65 | # eg: if the C function is "cpBodyAddShape", then the JS name will be "bodyWithAddShape" 66 | ## For OpenGL ES add "gl" 67 | function_prefix_to_remove = gl 68 | 69 | # Free functions to be parsed 70 | functions_to_parse = gl(.*) 71 | 72 | # Free functions not to parse 73 | ## Add here all the functions that should not be bound 74 | functions_to_ignore = glGetTexParameteriv, glGetUniformiv, 75 | 76 | # Free functions properties 77 | # Options 78 | # manual Means that the class is manually bound. No binding info will generated, but it can be used. 79 | # name:"newname" New name of the class 80 | function_properties = 81 | glGenBuffers = name:"_createBuffer"; manual, 82 | glGenFramebuffers = name:"_createFramebuffer"; manual, 83 | glGenRenderbuffers = name:"_createRenderbuffer"; manual, 84 | glGenTextures = name:"_createTexture"; manual, 85 | 86 | glDeleteBuffers = name:"_deleteBuffer"; manual, 87 | glDeleteFramebuffers = name:"_deleteFramebuffer"; manual, 88 | glDeleteRenderbuffers = name:"_deleteRenderbuffer"; manual, 89 | glDeleteTextures = name:"_deleteTexture"; manual, 90 | 91 | glGetShaderiv = name:"_getShaderParameter"; manual, 92 | glGetProgramiv = name:"_getProgramParameter"; manual, 93 | 94 | glGetProgramInfoLog = manual, 95 | glGetShaderInfoLog = manual, 96 | glGetShaderSource = manual, 97 | glShaderSource = manual, 98 | glGetActiveAttrib = manual, 99 | glGetActiveUniform = manual, 100 | glGetAttachedShaders = manual, 101 | 102 | glGetTexParameterfv = name:"getTexParameter"; manual, 103 | glGetUniformfv = name:"_getUniform"; manual, 104 | 105 | # 106 | # Struct properties 107 | # options: 108 | # opaque The structure will be treated as 'opaque' and can't not be inspected from JS. 109 | # Opaque structures are much faster to generate than 'manual' or 'automatic' structures 110 | # manual:[func] Manual conversion is provided for this structures. jsval_to_structname() and structname_to_jsval shall exists in your project 111 | # If "func" is passed, it will call that conversion function 112 | struct_properties = 113 | 114 | # 115 | # constants properties 116 | # options: 117 | # prefix_to_remove= Prefix to be removed from the parsed constants 118 | constant_properties = prefix_to_remove = GL_, 119 | 120 | # 121 | # Object oriented C library ? 122 | # If so, convert C-like API to object oriented API 123 | # This will generate JavaScript code that will call the C API in a Object Oriented manner. 124 | # The generated code might need to be manually modified 125 | # 126 | ## OpenGL doesn't have an OO API. 127 | objects_from_c_functions = 128 | 129 | # BridgeSupport file 130 | bridge_support_file = ./opengles20.bridgesupport 131 | 132 | # File that contains information that complements BridgeSupport (not present on BridgeSupport file) 133 | ## None, since OpenGL has no classes 134 | complement_file = 135 | -------------------------------------------------------------------------------- /configs/system/gen_system_bridgesupport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # run this script from chipmunk include directory 4 | # cd cocos2d-iphone/externals/Chipmunk/include/chipmunk 5 | # 6 | gen_bridge_metadata -F complete --no-64-bit -c '-DNDEBUG -I.' *.h -o ../jsbindings/configs/system/system.bridgesupport 7 | -------------------------------------------------------------------------------- /configs/system/system.bridgesupport: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /configs/system/system_jsb.ini: -------------------------------------------------------------------------------- 1 | [system] 2 | 3 | # prefix that will be removed from the ObjC classes in order to generate the JS classes 4 | # ex: If the class name is CCNode, then on JavaScript it will be Node 5 | ## None, since system has no Objective-C classes 6 | obj_class_prefix_to_remove = 7 | 8 | # Classes to generate. Use '*' to generate all the parsed classes. 9 | # Subclasses will be parsed as well. 10 | # ex: If CCSprite is parsed, then CCNode and NSObject will be parsed as well 11 | # It supports regular expressions to match class names. 12 | # eg: all cocos2d actions ending in 'By': CC(.*)By 13 | ## None, since system has no Objective-C classes 14 | classes_to_parse = 15 | 16 | # Classes to ignore. 17 | # It is a good idea to add classes that you don't want to have a proxy object. Usually internal classes, 18 | # or classes that are already native on JavaScript should be added here. 19 | # It supports regular expressions to match class names. 20 | # eg: all NS classes: NS(.*) 21 | ## None, since system has no Objective-C classes 22 | classes_to_ignore = 23 | 24 | # Class properties 25 | # Options 26 | # manual Means that the class is manually bound. No binding info will generated, but it can be used. 27 | class_properties = 28 | 29 | # Whether or not to generate constructors from base classes for the current class. 30 | # In JavaScript, the "constructors" or "static methods" are not "inherited". 31 | # It is recommended to set it to "auto". 32 | # Options: 33 | # False: Don't inherited 34 | # True: Inherit all class methods from all ancestors 35 | # Auto: Inherit only if it has no class constructors. Stop when the fist class constructor is added. 36 | ## Ignored, since system has no classes 37 | inherit_class_methods = Auto 38 | 39 | # Method properties 40 | # options: 41 | # name:"js_name" Rename methods. 42 | # ignore This method will be ignored. 43 | # callback This method is a callback. It will be invoked from Objective-C 44 | # optional_args_since:2 It means that all arguments starting from the 2nd argument are optionals 45 | # variadic_2_array It means that all arguments are variadic, and an Array will be created with them 46 | ## None, since system has not methods 47 | method_properties = 48 | 49 | # Files that are going to be imported by the auto-generated files. 50 | # Useful to declare subclasses of an already bound project 51 | # eg: manual bindings for NSObject 52 | import_files = LocalStorage.h 53 | 54 | compatible_with_cpp = True 55 | 56 | # The prefix will be removed from function name. 57 | # eg: if the C function is "cpBodyAddShape", then the JS name will be "bodyWithAddShape" 58 | ## For system add "cp" 59 | function_prefix_to_remove = localStorage 60 | 61 | # Free functions to be parsed 62 | functions_to_parse = localStorage(.*) 63 | 64 | # Free functions not to parse 65 | ## Add here all system "private" and "unsafe" functions 66 | ## cpv is not wrapped because it uses a function in JS, which is faster 67 | functions_to_ignore = 68 | 69 | # 70 | # Struct properties 71 | # options: 72 | # opaque The structure will be treated as 'opaque' and can't not be inspected from JS. 73 | # Opaque structures are much faster to generate than 'manual' or 'automatic' strcutures 74 | # manual:[func] Manual conversion is provided for this structures. jsval_to_structname() and structname_to_jsval shall exists in your project 75 | # If "func" is passed, it will call that conversion function 76 | struct_properties = 77 | 78 | # 79 | # Object oriented C library ? 80 | # If so, convert C-like API to object oriented API 81 | # This will generate JavaScript code that will call the C API in a Object Oriented manner. 82 | # The generated code might need to be manually modified 83 | # 84 | ## system has an OO API. 85 | objects_from_c_functions = 86 | 87 | # BridgeSupport file 88 | bridge_support_file = ./system.bridgesupport 89 | 90 | # File that contains information that complements BridgeSupport (not present on BridgeSupport file) 91 | ## None, since system has no classes 92 | complement_file = 93 | 94 | -------------------------------------------------------------------------------- /docs/jsb.graffle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zynga/jsbindings/49bed0b93300dc6297fdd05f98a4ce099f1fb35f/docs/jsb.graffle -------------------------------------------------------------------------------- /docs/jsb_callbacks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zynga/jsbindings/49bed0b93300dc6297fdd05f98a4ce099f1fb35f/docs/jsb_callbacks.png -------------------------------------------------------------------------------- /docs/jsb_calls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zynga/jsbindings/49bed0b93300dc6297fdd05f98a4ce099f1fb35f/docs/jsb_calls.png -------------------------------------------------------------------------------- /docs/jsb_files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zynga/jsbindings/49bed0b93300dc6297fdd05f98a4ce099f1fb35f/docs/jsb_files.png -------------------------------------------------------------------------------- /docs/jsb_instance_call.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zynga/jsbindings/49bed0b93300dc6297fdd05f98a4ce099f1fb35f/docs/jsb_instance_call.png -------------------------------------------------------------------------------- /docs/jsb_intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zynga/jsbindings/49bed0b93300dc6297fdd05f98a4ce099f1fb35f/docs/jsb_intro.png -------------------------------------------------------------------------------- /docs/jsb_new_class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zynga/jsbindings/49bed0b93300dc6297fdd05f98a4ce099f1fb35f/docs/jsb_new_class.png -------------------------------------------------------------------------------- /generate_complement.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # ---------------------------------------------------------------------------- 4 | # Simple regular expression that obtains super class, protocols 5 | # and properties from Obj-C header files 6 | # ---------------------------------------------------------------------------- 7 | # 8 | # Author: Ricardo Quesada 9 | # Copyright 2012 (C) Zynga, Inc 10 | # 11 | # License: MIT 12 | # 13 | ''' 14 | Parses objective-c header files and obtains protocol information, class hierarchy information and properties information since 15 | this information is not present in BridgeSupport. 16 | ''' 17 | 18 | __docformat__ = 'restructuredtext' 19 | 20 | 21 | # python 22 | import sys 23 | import re 24 | import getopt 25 | import ast 26 | 27 | 28 | class ObjC(object): 29 | def __init__(self, filenames, exception_file, output_file, verbose): 30 | self.filenames = filenames 31 | self.entries = {} 32 | self.output = output_file 33 | self.exception = exception_file 34 | self.verbose = verbose 35 | 36 | def log(self, what): 37 | if self.verbose: 38 | print what 39 | 40 | def parse_exception_file(self): 41 | if self.exception: 42 | f = open(self.exception) 43 | self.entries = ast.literal_eval(f.read()) 44 | f.close() 45 | 46 | def parse(self): 47 | 48 | self.parse_exception_file() 49 | 50 | for filename in self.filenames: 51 | f = open(filename, 'r') 52 | l = f.readlines() 53 | 54 | # regexp based on Objective Pascal parser ( http://www.objectivepascal.com/ ) 55 | regex_objc_class = r"^\s*@interface\s+([\S]+)\s*:\s*([\w]+)\s*(<.*>)*" 56 | regex_objc_class_extension = r"^\s*@interface\s+([\S]+)\s*\(\s*([\w]+)\s*\)\s*" 57 | regex_objc_property_attributes = r"^@property\s*\(([^)]*)\)\s*([a-zA-Z_0-9]+)\s*(<.*>)?(\bint\b|\blong\b|\bchar\b)?(\*)*\s*(.*)\s*;" 58 | regex_objc_protocol = r"^\s*@protocol\s+([\S]+)\s*(<.*>)*" 59 | regex_obj_end = r"^\s*@end\s*$" 60 | 61 | current_class = None 62 | for line in l: 63 | interface = re.match(regex_objc_class, line) 64 | interface_ext = re.match(regex_objc_class_extension, line) 65 | property_attribs = re.match(regex_objc_property_attributes, line) 66 | protocol_declaration = re.match(regex_objc_protocol, line) 67 | end = re.match(regex_obj_end, line) 68 | 69 | # Found @interface 70 | if interface: 71 | classname = interface.group(1) 72 | subclass = interface.group(2) 73 | protocols = interface.group(3) 74 | 75 | if classname in self.entries: 76 | self.log('Key already on dictionary %s\n' % classname) 77 | else: 78 | if protocols: 79 | # strip '<>' 80 | protocols = protocols.strip('<> ') 81 | 82 | # remove spaces 83 | protocols = protocols.replace(' ', '') 84 | 85 | # split by ',' 86 | protocols = protocols.split(',') 87 | else: 88 | protocols = [] 89 | 90 | self.entries[classname] = {'subclass': subclass, 'protocols': protocols} 91 | 92 | current_class = classname 93 | self.log('--> %s' % current_class) 94 | 95 | # Found @interface bis 96 | elif interface_ext: 97 | classname = interface_ext.group(1) 98 | current_class = classname 99 | self.log('--> %s' % current_class) 100 | 101 | # Found @protocol 102 | elif protocol_declaration: 103 | classname = protocol_declaration.group(1) 104 | protocols = protocol_declaration.group(2) 105 | 106 | if classname in self.entries: 107 | self.log('Key already on dictionary %s\n' % classname) 108 | else: 109 | if protocols: 110 | # strip '<>' 111 | protocols = protocols.strip('<> ') 112 | 113 | # remove spaces 114 | protocols = protocols.replace(' ', '') 115 | 116 | # split by ',' 117 | protocols = protocols.split(',') 118 | else: 119 | protocols = [] 120 | 121 | self.entries[classname] = {'protocols': protocols} 122 | current_class = classname 123 | 124 | # Found @property 125 | elif property_attribs: 126 | if not current_class: 127 | raise Exception("Fatal: Unparented attrib: %s (%s)" % (str(property_attribs.groups()), filename)) 128 | if not 'properties' in self.entries[current_class]: 129 | self.entries[current_class]['properties'] = {} 130 | l = [] 131 | # 1: attributes 132 | # 2: type 133 | # 3: type protocol (optional) 134 | # 4: type 2nd word like int, long, char (optional) 135 | # 5: type pointer '*' (optional) 136 | # 6: property name 137 | l.append(property_attribs.group(1)) 138 | 139 | if property_attribs.group(4): 140 | l.append("%s %s%s%s" % (property_attribs.group(2), property_attribs.group(3), property_attribs.group(4), property_attribs.group(5))) 141 | else: 142 | l.append("%s%s%s%s" % (property_attribs.group(2), property_attribs.group(3), property_attribs.group(4), property_attribs.group(5))) 143 | 144 | if ' ' in property_attribs.group(6) or property_attribs.group(6) == None: 145 | sys.stderr.write('Error. Could not add property. File:%s line:%s\n' % (filename, line)) 146 | print property_attribs.groups() 147 | else: 148 | 149 | attrib_name = property_attribs.group(6) 150 | # XXX HACK XXX. I should fix the regexp instead of doing this hack 151 | # strip possible '*' from it 152 | attrib_name = attrib_name.replace('*', '') 153 | self.entries[current_class]['properties'][attrib_name] = l 154 | 155 | # Found @end 156 | elif end: 157 | self.log('<-- %s (%s)' % (current_class, filename)) 158 | current_class = None 159 | else: 160 | # ignore 161 | pass 162 | f.close() 163 | 164 | self.write_output() 165 | 166 | def write_output(self): 167 | if not self.output: 168 | fd = sys.stdout 169 | else: 170 | fd = open(self.output, 'w') 171 | 172 | fd.write(str(self.entries)) 173 | 174 | 175 | def help(): 176 | print "%s v1.0 - An utility to obtain superclass and protocols from an Objective-C interface" % sys.argv[0] 177 | print "Usage:" 178 | print "\t-o --output\tFile that will have the output. Default: stdout" 179 | print "\t-e --exception\tFile that contains the exception rules for the parser. Exception rules have precedence over the parsed data" 180 | print "\t\t\tUseful if the parser generates invalid or wrong info for certain classes." 181 | print "\t-v --verbose\tVerbose output. Useful to find possible errors." 182 | print "\nExample:" 183 | print "\t%s -o cocos2d-mac-class_hierarchy-protocols.txt -e cocos2d-mac-class_hierarchy-protocols-exceptions.txt *.h Support/*.h Platforms/*.h Platforms/Mac/*.h " % sys.argv[0] 184 | sys.exit(-1) 185 | 186 | if __name__ == "__main__": 187 | if len(sys.argv) == 1: 188 | help() 189 | 190 | input_file = None 191 | output_file = None 192 | verbose = False 193 | 194 | argv = sys.argv[1:] 195 | try: 196 | opts, args = getopt.getopt(argv, "e:o:v", ["exception=", "output=", "verbose"]) 197 | 198 | for opt, arg in opts: 199 | if opt in ("-e", "--exception"): 200 | input_file = arg 201 | if opt in ("-o", "--output"): 202 | output_file = arg 203 | if opt in ("-v", "--verbose"): 204 | verbose = True 205 | 206 | except getopt.GetoptError, e: 207 | print e 208 | opts, args = getopt.getopt(argv, "", []) 209 | 210 | if args == None: 211 | help() 212 | 213 | instance = ObjC(args, input_file, output_file, verbose) 214 | instance.parse() 215 | print 'Ok' 216 | -------------------------------------------------------------------------------- /plugin_jsb_chipmunk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # ---------------------------------------------------------------------------- 3 | # Plugin to generate better enums for chipmunk 4 | # 5 | # Author: Ricardo Quesada 6 | # Copyright 2013 (C) Zynga, Inc 7 | # 8 | # License: MIT 9 | # ---------------------------------------------------------------------------- 10 | ''' 11 | Plugin to generate better enums for chipmunk 12 | ''' 13 | 14 | __docformat__ = 'restructuredtext' 15 | 16 | 17 | # python modules 18 | #import re 19 | 20 | # plugin modules 21 | from generate_jsb import JSBGenerateConstants 22 | 23 | 24 | # 25 | # 26 | # Plugin to generate better enums for Chipmunk 27 | # 28 | # 29 | class JSBGenerateConstants_CP(JSBGenerateConstants): 30 | 31 | def get_name_for_constant(self, name): 32 | if name.startswith('CP_'): 33 | return name[3:] 34 | return None 35 | -------------------------------------------------------------------------------- /plugin_jsb_cocos2d.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # ---------------------------------------------------------------------------- 3 | # Plugin to generate better enums for cocos2d 4 | # 5 | # Author: Ricardo Quesada 6 | # Copyright 2013 (C) Zynga, Inc 7 | # 8 | # License: MIT 9 | # ---------------------------------------------------------------------------- 10 | ''' 11 | Plugin to generate better enums for cocos2d 12 | ''' 13 | 14 | __docformat__ = 'restructuredtext' 15 | 16 | 17 | # python modules 18 | import re 19 | 20 | # plugin modules 21 | from generate_jsb import JSBGenerateConstants, JSBGenerateFunctions, JSBGenerateClasses 22 | 23 | 24 | # 25 | # 26 | # Plugin to generate better constants for cocos2d 27 | # 28 | # 29 | class JSBGenerateConstants_CC(JSBGenerateConstants): 30 | 31 | def get_name_for_constant(self, name): 32 | ok = False 33 | if name.startswith('kCC'): 34 | name = name[3:] 35 | ok = True 36 | 37 | if name.startswith('CC'): 38 | name = name[2:] 39 | ok = True 40 | 41 | if ok: 42 | n = [] 43 | array = re.findall('[A-Z][^A-Z]*', name) 44 | if array and len(array) > 0: 45 | prev = '' 46 | prev_e_len = 0 47 | for e in array: 48 | e = e.upper() 49 | # Append all single letters together 50 | if re.match('[A-Z][_0-9]?$', e) and len(n) >= 1 and prev_e_len == 1: 51 | prev = prev + e 52 | n[-1] = prev 53 | else: 54 | n.append(e) 55 | prev = e 56 | prev_e_len = len(e) 57 | name = '_'.join(n) 58 | name = name.replace('__', '_') 59 | else: 60 | name = None 61 | 62 | return name 63 | 64 | 65 | # 66 | # 67 | # OpenGL ES 2.0 / WebGL function plugin 68 | # 69 | # 70 | class JSBGenerateFunctions_CC(JSBGenerateFunctions): 71 | 72 | def convert_function_name_to_js(self, function_name): 73 | 74 | if function_name.startswith('ccGL'): 75 | return 'gl' + function_name[4:] 76 | return super(JSBGenerateFunctions_CC, self).convert_function_name_to_js(function_name) 77 | 78 | 79 | # 80 | # 81 | # OpenGL ES 2.0 / WebGL function plugin 82 | # 83 | # 84 | class JSBGenerateClasses_CC(JSBGenerateClasses): 85 | 86 | def __init__(self, config): 87 | super(JSBGenerateClasses_CC, self).__init__(config) 88 | 89 | # Extend supported types 90 | self.args_js_special_type_conversions['cc_fontdef'] = ['JSB_jsval_to_CCFontDefinition', 'CCFontDefinition*'] 91 | self.supported_declared_types['CCFontDefinition*'] = 'cc_fontdef' 92 | 93 | # 94 | # Overriden methods 95 | # 96 | def validate_argument(self, arg): 97 | # Treat GLchar* as null-terminated char* 98 | if arg['declared_type'] == 'GLchar*' or arg['declared_type'] == 'char*' or arg['declared_type'] == 'char*': 99 | return ('char*', 'char*') 100 | # if arg['declared_type'] == 'CCFontDefinition*': 101 | # return ('cc_fontdef','CCFontDefinition') 102 | 103 | return super(JSBGenerateClasses_CC, self).validate_argument(arg) 104 | 105 | def convert_js_to_objc(self, js_type, objc_type): 106 | # print js_type, objc_type 107 | return super(JSBGenerateClasses_CC, self).convert_js_to_objc(js_type, objc_type) 108 | 109 | 110 | -------------------------------------------------------------------------------- /plugin_jsb_gl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # ---------------------------------------------------------------------------- 3 | # Plugin to generate OpenGL ES 2.0 / WebGL code for JSB 4 | # 5 | # Author: Ricardo Quesada 6 | # Copyright 2013 (C) Zynga, Inc 7 | # 8 | # License: MIT 9 | # ---------------------------------------------------------------------------- 10 | ''' 11 | Plugin to generate OpenGL ES 2.0 / WebGL code for JSB 12 | ''' 13 | 14 | __docformat__ = 'restructuredtext' 15 | 16 | 17 | # python modules 18 | import re 19 | 20 | # plugin modules 21 | from generate_jsb import JSBGenerateFunctions 22 | 23 | 24 | # 25 | # 26 | # OpenGL ES 2.0 / WebGL function plugin 27 | # 28 | # 29 | class JSBGenerateFunctions_GL(JSBGenerateFunctions): 30 | 31 | def __init__(self, config): 32 | super(JSBGenerateFunctions_GL, self).__init__(config) 33 | 34 | # TypedArray ivars 35 | self._current_typedarray = None 36 | self._with_count = False 37 | self._typedarray_dt = ['TypedArray/Sequence', 'ArrayBufferView'] 38 | 39 | # Extend supported types 40 | self.args_js_special_type_conversions['TypedArray'] = ['JSB_jsval_typedarray_to_dataptr', 'void*'] 41 | self.args_js_special_type_conversions['ArrayBufferView'] = ['JSB_get_arraybufferview_dataptr', 'void*'] 42 | 43 | # Other supported functions 44 | self.supported_functions_without_count = ['glReadPixels', 'glDrawElements', 'glTexImage2D', 'glTexSubImage2D', 'glCompressedTexImage2D', 'glCompressedTexSubImage2D'] 45 | self.supported_functions_with_count = ['glBufferData', 'glBufferSubData'] 46 | 47 | # Only valid when _with_count is enabled 48 | self.args_to_ignore_in_js = ['count', 'size'] 49 | 50 | # Functions that should have an _ as prefix 51 | self.functions_with_underscore = [ 52 | 'glCreateShader', 'glCreateProgram', 53 | 'glDeleteShader', 'glDeleteProgram', 54 | 'glGetShaderInfoLog', 'glGetProgramInfoLog', 55 | 'glAttachShader', 'glLinkProgram', 'glUseProgram', 'glCompileShader', 56 | 'glGetAttribLocation', 'glGetUniformLocation', 'glGetShaderSource', 'glShaderSource', 57 | 'glValidateProgram', 58 | 'glGetActiveUniform', 'glGetActiveAttrib', 'glGetAttachedShaders', 59 | 'glTexImage2D', 'glTexSubImage2D', 60 | ] 61 | 62 | # 63 | # Overriden methods 64 | # 65 | def convert_js_to_objc(self, js_type, objc_type): 66 | if js_type == 'TypedArray': 67 | if not self._current_typedarray: 68 | raise Exception("Logic error in GL plugin") 69 | js_convert = self.args_js_special_type_conversions[js_type][0] 70 | return js_convert + '( cx, %%(jsval)s, &count, %%(retval)s, %s)' % (self._current_typedarray) 71 | elif js_type == 'ArrayBufferView': 72 | if not self._current_typedarray: 73 | raise Exception("Logic error in GL plugin") 74 | js_convert = self.args_js_special_type_conversions[js_type][0] 75 | return js_convert + '( cx, %(jsval)s, &count, %(retval)s)' 76 | else: 77 | return super(JSBGenerateFunctions_GL, self).convert_js_to_objc(js_type, objc_type) 78 | 79 | def generate_argument(self, i, arg_js_type, arg_declared_type): 80 | template = super(JSBGenerateFunctions_GL, self).generate_argument(i, arg_js_type, arg_declared_type) 81 | if arg_js_type in ['TypedArray', 'ArrayBufferView']: 82 | template = '\tGLsizei count;\n' + template 83 | return template 84 | 85 | def generate_function_c_call_arg(self, i, dt): 86 | 87 | if re.match('glUniformMatrix[2-4][fi]v$', self._current_funcname) and i == 0: 88 | # special case for glUniformMatrix4fv since '1' needs to be added as a second argument 89 | return 'arg0, 1' 90 | 91 | if self._current_typedarray and dt in self._typedarray_dt: 92 | ret = '' 93 | if self._with_count: 94 | ret += ', count' 95 | ret += ', (%s*)arg%d ' % (self._current_cast, i) 96 | return ret 97 | return super(JSBGenerateFunctions_GL, self).generate_function_c_call_arg(i, dt) 98 | 99 | def convert_function_name_to_js(self, function_name): 100 | 101 | use_underscore = False 102 | # It is possible to add the "name" parameter in opengl_jsb.ini, 103 | # but it easier with a plugin 104 | 105 | if function_name in self.functions_with_underscore: 106 | use_underscore = True 107 | # elif re.match('gl\S+([1-4])([fi])v$', function_name): 108 | # use_underscore = True 109 | elif re.match('glBind.*$', function_name): 110 | use_underscore = True 111 | 112 | if use_underscore: 113 | name = function_name[2].lower() + function_name[3:] 114 | return "_%s" % name 115 | return super(JSBGenerateFunctions_GL, self).convert_function_name_to_js(function_name) 116 | 117 | def validate_argument(self, arg): 118 | if self._current_typedarray: 119 | 120 | # Special case: JS UniformMatrix receives 3 args, while C receives 4. C 'count' should be replaced with '1' 121 | if re.match('glUniformMatrix[2-4][fi]v$', self._current_funcname) and 'name' in arg and arg['name'] == 'count': 122 | return (None, None) 123 | 124 | # Skip count, size: ivars for glUniformXXX, glBufferData, etc... 125 | if self._with_count and 'name' in arg and arg['name'] in self.args_to_ignore_in_js: 126 | return (None, None) 127 | 128 | # Vector thing 129 | if arg['type'] == '^i': 130 | return ('TypedArray', 'TypedArray/Sequence') 131 | elif arg['type'] == '^v': 132 | return ('ArrayBufferView', 'ArrayBufferView') 133 | else: 134 | # Special case: glVertexAttribPointer 135 | if self._current_funcname == 'glVertexAttribPointer' and arg['type'] == '^v': 136 | # Argument is an integer, but cast it as a void * 137 | return ('i', 'GLvoid*') 138 | elif self._current_funcname in ['glGetAttribLocation', 'glBindAttribLocation', 'glGetUniformLocation'] and arg['type'] == '*': 139 | return ('char*', 'char*') 140 | 141 | return super(JSBGenerateFunctions_GL, self).validate_argument(arg) 142 | 143 | def generate_function_binding(self, function): 144 | func_name = function['name'] 145 | 146 | self._current_funcname = func_name 147 | self._current_typedarray = None 148 | self._current_cast = 'GLvoid' 149 | self._with_count = False 150 | 151 | t = None 152 | # Testing generic vector functions 153 | r = re.match('gl\S+([1-4])([fi])v$', func_name) 154 | if r: 155 | t = 'f32' if r.group(2) == 'f' else 'i32' 156 | #self._with_count = (re.match('glVertexAttrib[1-4][fi]v', func_name) == None) 157 | else: 158 | if func_name in self.supported_functions_without_count: 159 | t = 'v' 160 | elif func_name in self.supported_functions_with_count: 161 | t = 'v' 162 | self._with_count = True 163 | 164 | if t == 'f32': 165 | self._current_typedarray = 'js::ArrayBufferView::TYPE_FLOAT32' 166 | self._current_cast = 'GLfloat' 167 | elif t == 'i32': 168 | self._current_typedarray = 'js::ArrayBufferView::TYPE_INT32' 169 | self._current_cast = 'GLint' 170 | elif t == 'u8': 171 | self._current_typedarray = 'js::ArrayBufferView::TYPE_UINT8' 172 | self._current_cast = 'GLuint8' 173 | elif t == 'v': 174 | self._current_typedarray = 'void' 175 | self._current_cast = 'GLvoid' 176 | 177 | return super(JSBGenerateFunctions_GL, self).generate_function_binding(function) 178 | -------------------------------------------------------------------------------- /src/auto/jsb_CocosBuilderReader_classes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c CocosBuilderReader_jsb.ini" on 2013-10-30 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOSBUILDERREADER 8 | 9 | #import "jsb_NS_manual.h" 10 | #import "CCBReader.h" 11 | #import "CCBAnimationManager.h" 12 | 13 | /* 14 | * CCBAnimationManager 15 | */ 16 | #pragma mark - CCBAnimationManager 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | void JSB_CCBAnimationManager_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 23 | 24 | // Manually generated methods 25 | JSBool JSB_CCBAnimationManager_setCompletedAnimationCallbackBlock_(JSContext *cx, uint32_t argc, jsval *vp); 26 | 27 | 28 | extern JSObject *JSB_CCBAnimationManager_object; 29 | extern JSClass *JSB_CCBAnimationManager_class; 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | /* Proxy class */ 36 | @interface JSB_CCBAnimationManager : JSB_NSObject 37 | { 38 | } 39 | @end 40 | 41 | /* 42 | * CCBReader 43 | */ 44 | #pragma mark - CCBReader 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | void JSB_CCBReader_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 51 | 52 | 53 | 54 | extern JSObject *JSB_CCBReader_object; 55 | extern JSClass *JSB_CCBReader_class; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | /* Proxy class */ 62 | @interface JSB_CCBReader : JSB_NSObject 63 | { 64 | } 65 | @end 66 | 67 | 68 | #endif // JSB_INCLUDE_COCOSBUILDERREADER 69 | -------------------------------------------------------------------------------- /src/auto/jsb_CocosBuilderReader_classes_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c CocosBuilderReader_jsb.ini" on 2013-10-30 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOSBUILDERREADER 8 | 9 | #import "jsb_NS_manual.h" 10 | #import "CCBReader.h" 11 | #import "CCBAnimationManager.h" 12 | JSB_CCBAnimationManager_createClass(_cx, CocosBuilderReader, "AnimationManager"); 13 | JSB_CCBReader_createClass(_cx, CocosBuilderReader, "_Reader"); 14 | 15 | 16 | #endif // JSB_INCLUDE_COCOSBUILDERREADER 17 | -------------------------------------------------------------------------------- /src/auto/jsb_CocosDenshion_classes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c CocosDenshion_jsb.ini" on 2013-10-30 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOSDENSHION 8 | 9 | #import "jsb_NS_manual.h" 10 | 11 | /* 12 | * SimpleAudioEngine 13 | */ 14 | #pragma mark - SimpleAudioEngine 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | void JSB_SimpleAudioEngine_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 21 | 22 | 23 | 24 | extern JSObject *JSB_SimpleAudioEngine_object; 25 | extern JSClass *JSB_SimpleAudioEngine_class; 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | /* Proxy class */ 32 | @interface JSB_SimpleAudioEngine : JSB_NSObject 33 | { 34 | } 35 | @end 36 | 37 | 38 | #endif // JSB_INCLUDE_COCOSDENSHION 39 | -------------------------------------------------------------------------------- /src/auto/jsb_CocosDenshion_classes_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c CocosDenshion_jsb.ini" on 2013-10-30 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOSDENSHION 8 | 9 | #import "jsb_NS_manual.h" 10 | JSB_SimpleAudioEngine_createClass(_cx, CocosDenshion, "AudioEngine"); 11 | 12 | 13 | #endif // JSB_INCLUDE_COCOSDENSHION 14 | -------------------------------------------------------------------------------- /src/auto/jsb_CocosDenshion_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c CocosDenshion_jsb.ini" on 2013-10-30 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOSDENSHION 8 | 9 | #import "jsb_NS_manual.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | 20 | #endif // JSB_INCLUDE_COCOSDENSHION 21 | -------------------------------------------------------------------------------- /src/auto/jsb_CocosDenshion_functions.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c CocosDenshion_jsb.ini" on 2013-10-30 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOSDENSHION 8 | 9 | #import "jsb_NS_manual.h" 10 | 11 | #import "jsfriendapi.h" 12 | #import "jsb_config.h" 13 | #import "jsb_core.h" 14 | #import "jsb_basic_conversions.h" 15 | #import "jsb_CocosDenshion_functions.h" 16 | 17 | 18 | #endif // JSB_INCLUDE_COCOSDENSHION 19 | -------------------------------------------------------------------------------- /src/auto/jsb_CocosDenshion_functions_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c CocosDenshion_jsb.ini" on 2013-10-30 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOSDENSHION 8 | 9 | #import "jsb_NS_manual.h" 10 | 11 | 12 | #endif // JSB_INCLUDE_COCOSDENSHION 13 | -------------------------------------------------------------------------------- /src/auto/jsb_chipmunk_auto_classes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c chipmunk_jsb.ini" on 2013-10-30 4 | * Script version: v0.6 5 | */ 6 | #include "jsb_config.h" 7 | #if JSB_INCLUDE_CHIPMUNK 8 | 9 | #include "jsb_chipmunk_manual.h" 10 | extern JSObject *JSB_cpConstraint_object; 11 | extern JSClass *JSB_cpConstraint_class; 12 | void JSB_cpConstraint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 13 | extern JSObject *JSB_cpGrooveJoint_object; 14 | extern JSClass *JSB_cpGrooveJoint_class; 15 | void JSB_cpGrooveJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 16 | extern JSObject *JSB_cpSimpleMotor_object; 17 | extern JSClass *JSB_cpSimpleMotor_class; 18 | void JSB_cpSimpleMotor_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 19 | extern JSObject *JSB_cpPivotJoint_object; 20 | extern JSClass *JSB_cpPivotJoint_class; 21 | void JSB_cpPivotJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 22 | extern JSObject *JSB_cpPinJoint_object; 23 | extern JSClass *JSB_cpPinJoint_class; 24 | void JSB_cpPinJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 25 | extern JSObject *JSB_cpSlideJoint_object; 26 | extern JSClass *JSB_cpSlideJoint_class; 27 | void JSB_cpSlideJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 28 | extern JSObject *JSB_cpGearJoint_object; 29 | extern JSClass *JSB_cpGearJoint_class; 30 | void JSB_cpGearJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 31 | extern JSObject *JSB_cpDampedRotarySpring_object; 32 | extern JSClass *JSB_cpDampedRotarySpring_class; 33 | void JSB_cpDampedRotarySpring_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 34 | extern JSObject *JSB_cpDampedSpring_object; 35 | extern JSClass *JSB_cpDampedSpring_class; 36 | void JSB_cpDampedSpring_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 37 | extern JSObject *JSB_cpRatchetJoint_object; 38 | extern JSClass *JSB_cpRatchetJoint_class; 39 | void JSB_cpRatchetJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 40 | extern JSObject *JSB_cpRotaryLimitJoint_object; 41 | extern JSClass *JSB_cpRotaryLimitJoint_class; 42 | void JSB_cpRotaryLimitJoint_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 43 | extern JSObject *JSB_cpArbiter_object; 44 | extern JSClass *JSB_cpArbiter_class; 45 | void JSB_cpArbiter_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 46 | extern JSObject *JSB_cpSpace_object; 47 | extern JSClass *JSB_cpSpace_class; 48 | void JSB_cpSpace_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 49 | extern JSObject *JSB_cpBody_object; 50 | extern JSClass *JSB_cpBody_class; 51 | void JSB_cpBody_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 52 | extern JSObject *JSB_cpShape_object; 53 | extern JSClass *JSB_cpShape_class; 54 | void JSB_cpShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 55 | extern JSObject *JSB_cpCircleShape_object; 56 | extern JSClass *JSB_cpCircleShape_class; 57 | void JSB_cpCircleShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 58 | extern JSObject *JSB_cpSegmentShape_object; 59 | extern JSClass *JSB_cpSegmentShape_class; 60 | void JSB_cpSegmentShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 61 | extern JSObject *JSB_cpPolyShape_object; 62 | extern JSClass *JSB_cpPolyShape_class; 63 | void JSB_cpPolyShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 64 | 65 | 66 | #endif // JSB_INCLUDE_CHIPMUNK 67 | -------------------------------------------------------------------------------- /src/auto/jsb_chipmunk_auto_classes_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c chipmunk_jsb.ini" on 2013-10-30 4 | * Script version: v0.6 5 | */ 6 | #include "jsb_config.h" 7 | #if JSB_INCLUDE_CHIPMUNK 8 | 9 | #include "jsb_chipmunk_manual.h" 10 | JSB_cpConstraint_createClass(_cx, chipmunk, "Constraint"); 11 | JSB_cpGrooveJoint_createClass(_cx, chipmunk, "GrooveJoint"); 12 | JSB_cpSimpleMotor_createClass(_cx, chipmunk, "SimpleMotor"); 13 | JSB_cpPivotJoint_createClass(_cx, chipmunk, "PivotJoint"); 14 | JSB_cpPinJoint_createClass(_cx, chipmunk, "PinJoint"); 15 | JSB_cpSlideJoint_createClass(_cx, chipmunk, "SlideJoint"); 16 | JSB_cpGearJoint_createClass(_cx, chipmunk, "GearJoint"); 17 | JSB_cpDampedRotarySpring_createClass(_cx, chipmunk, "DampedRotarySpring"); 18 | JSB_cpDampedSpring_createClass(_cx, chipmunk, "DampedSpring"); 19 | JSB_cpRatchetJoint_createClass(_cx, chipmunk, "RatchetJoint"); 20 | JSB_cpRotaryLimitJoint_createClass(_cx, chipmunk, "RotaryLimitJoint"); 21 | JSB_cpArbiter_createClass(_cx, chipmunk, "Arbiter"); 22 | JSB_cpSpace_createClass(_cx, chipmunk, "Space"); 23 | JSB_cpBody_createClass(_cx, chipmunk, "Body"); 24 | JSB_cpShape_createClass(_cx, chipmunk, "Shape"); 25 | JSB_cpCircleShape_createClass(_cx, chipmunk, "CircleShape"); 26 | JSB_cpSegmentShape_createClass(_cx, chipmunk, "SegmentShape"); 27 | JSB_cpPolyShape_createClass(_cx, chipmunk, "PolyShape"); 28 | 29 | 30 | #endif // JSB_INCLUDE_CHIPMUNK 31 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D 8 | 9 | #import "jsb_NS_manual.h" 10 | #import "jsb_cocos2d_manual.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | JSBool JSB_ccCardinalSplineAt(JSContext *cx, uint32_t argc, jsval *vp); 16 | JSBool JSB_ccDrawArc(JSContext *cx, uint32_t argc, jsval *vp); 17 | JSBool JSB_ccDrawCardinalSpline(JSContext *cx, uint32_t argc, jsval *vp); 18 | JSBool JSB_ccDrawCatmullRom(JSContext *cx, uint32_t argc, jsval *vp); 19 | JSBool JSB_ccDrawCircle(JSContext *cx, uint32_t argc, jsval *vp); 20 | JSBool JSB_ccDrawColor4B(JSContext *cx, uint32_t argc, jsval *vp); 21 | JSBool JSB_ccDrawColor4F(JSContext *cx, uint32_t argc, jsval *vp); 22 | JSBool JSB_ccDrawCubicBezier(JSContext *cx, uint32_t argc, jsval *vp); 23 | JSBool JSB_ccDrawFree(JSContext *cx, uint32_t argc, jsval *vp); 24 | JSBool JSB_ccDrawInit(JSContext *cx, uint32_t argc, jsval *vp); 25 | JSBool JSB_ccDrawLine(JSContext *cx, uint32_t argc, jsval *vp); 26 | JSBool JSB_ccDrawPoint(JSContext *cx, uint32_t argc, jsval *vp); 27 | JSBool JSB_ccDrawQuadBezier(JSContext *cx, uint32_t argc, jsval *vp); 28 | JSBool JSB_ccDrawRect(JSContext *cx, uint32_t argc, jsval *vp); 29 | JSBool JSB_ccDrawSolidArc(JSContext *cx, uint32_t argc, jsval *vp); 30 | JSBool JSB_ccDrawSolidCircle(JSContext *cx, uint32_t argc, jsval *vp); 31 | JSBool JSB_ccDrawSolidRect(JSContext *cx, uint32_t argc, jsval *vp); 32 | JSBool JSB_ccGLBindTexture(JSContext *cx, uint32_t argc, jsval *vp); 33 | JSBool JSB_ccGLBindTexture2D(JSContext *cx, uint32_t argc, jsval *vp); 34 | JSBool JSB_ccGLBindTexture2DN(JSContext *cx, uint32_t argc, jsval *vp); 35 | JSBool JSB_ccGLBindVAO(JSContext *cx, uint32_t argc, jsval *vp); 36 | JSBool JSB_ccGLBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); 37 | JSBool JSB_ccGLBlendResetToCache(JSContext *cx, uint32_t argc, jsval *vp); 38 | JSBool JSB_ccGLDeleteProgram(JSContext *cx, uint32_t argc, jsval *vp); 39 | JSBool JSB_ccGLDeleteTexture(JSContext *cx, uint32_t argc, jsval *vp); 40 | JSBool JSB_ccGLDeleteTextureN(JSContext *cx, uint32_t argc, jsval *vp); 41 | JSBool JSB_ccGLEnable(JSContext *cx, uint32_t argc, jsval *vp); 42 | JSBool JSB_ccGLEnableVertexAttribs(JSContext *cx, uint32_t argc, jsval *vp); 43 | JSBool JSB_ccGLInvalidateStateCache(JSContext *cx, uint32_t argc, jsval *vp); 44 | JSBool JSB_ccGLUseProgram(JSContext *cx, uint32_t argc, jsval *vp); 45 | JSBool JSB_ccNextPOT(JSContext *cx, uint32_t argc, jsval *vp); 46 | JSBool JSB_ccPointSize(JSContext *cx, uint32_t argc, jsval *vp); 47 | JSBool JSB_ccSetProjectionMatrixDirty(JSContext *cx, uint32_t argc, jsval *vp); 48 | JSBool JSB_cc_fps_images_hd_len(JSContext *cx, uint32_t argc, jsval *vp); 49 | JSBool JSB_cc_fps_images_ipadhd_len(JSContext *cx, uint32_t argc, jsval *vp); 50 | JSBool JSB_cc_fps_images_len(JSContext *cx, uint32_t argc, jsval *vp); 51 | JSBool JSB_ccc4BFromccc4F(JSContext *cx, uint32_t argc, jsval *vp); 52 | JSBool JSB_ccc4FEqual(JSContext *cx, uint32_t argc, jsval *vp); 53 | JSBool JSB_ccc4FFromccc3B(JSContext *cx, uint32_t argc, jsval *vp); 54 | JSBool JSB_ccc4FFromccc4B(JSContext *cx, uint32_t argc, jsval *vp); 55 | JSBool JSB_ccp(JSContext *cx, uint32_t argc, jsval *vp); 56 | JSBool JSB_ccpAdd(JSContext *cx, uint32_t argc, jsval *vp); 57 | JSBool JSB_ccpAngle(JSContext *cx, uint32_t argc, jsval *vp); 58 | JSBool JSB_ccpAngleSigned(JSContext *cx, uint32_t argc, jsval *vp); 59 | JSBool JSB_ccpClamp(JSContext *cx, uint32_t argc, jsval *vp); 60 | JSBool JSB_ccpCompMult(JSContext *cx, uint32_t argc, jsval *vp); 61 | JSBool JSB_ccpCross(JSContext *cx, uint32_t argc, jsval *vp); 62 | JSBool JSB_ccpDistance(JSContext *cx, uint32_t argc, jsval *vp); 63 | JSBool JSB_ccpDistanceSQ(JSContext *cx, uint32_t argc, jsval *vp); 64 | JSBool JSB_ccpDot(JSContext *cx, uint32_t argc, jsval *vp); 65 | JSBool JSB_ccpForAngle(JSContext *cx, uint32_t argc, jsval *vp); 66 | JSBool JSB_ccpFromSize(JSContext *cx, uint32_t argc, jsval *vp); 67 | JSBool JSB_ccpFuzzyEqual(JSContext *cx, uint32_t argc, jsval *vp); 68 | JSBool JSB_ccpIntersectPoint(JSContext *cx, uint32_t argc, jsval *vp); 69 | JSBool JSB_ccpLength(JSContext *cx, uint32_t argc, jsval *vp); 70 | JSBool JSB_ccpLengthSQ(JSContext *cx, uint32_t argc, jsval *vp); 71 | JSBool JSB_ccpLerp(JSContext *cx, uint32_t argc, jsval *vp); 72 | JSBool JSB_ccpMidpoint(JSContext *cx, uint32_t argc, jsval *vp); 73 | JSBool JSB_ccpMult(JSContext *cx, uint32_t argc, jsval *vp); 74 | JSBool JSB_ccpNeg(JSContext *cx, uint32_t argc, jsval *vp); 75 | JSBool JSB_ccpNormalize(JSContext *cx, uint32_t argc, jsval *vp); 76 | JSBool JSB_ccpPerp(JSContext *cx, uint32_t argc, jsval *vp); 77 | JSBool JSB_ccpProject(JSContext *cx, uint32_t argc, jsval *vp); 78 | JSBool JSB_ccpRPerp(JSContext *cx, uint32_t argc, jsval *vp); 79 | JSBool JSB_ccpRotate(JSContext *cx, uint32_t argc, jsval *vp); 80 | JSBool JSB_ccpRotateByAngle(JSContext *cx, uint32_t argc, jsval *vp); 81 | JSBool JSB_ccpSegmentIntersect(JSContext *cx, uint32_t argc, jsval *vp); 82 | JSBool JSB_ccpSub(JSContext *cx, uint32_t argc, jsval *vp); 83 | JSBool JSB_ccpToAngle(JSContext *cx, uint32_t argc, jsval *vp); 84 | JSBool JSB_ccpUnrotate(JSContext *cx, uint32_t argc, jsval *vp); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | 91 | #endif // JSB_INCLUDE_COCOS2D 92 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_functions_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D 8 | 9 | #import "jsb_NS_manual.h" 10 | #import "jsb_cocos2d_manual.h" 11 | JS_DefineFunction(_cx, cocos2d, "cardinalSplineAt", JSB_ccCardinalSplineAt, 6, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 12 | JS_DefineFunction(_cx, cocos2d, "drawArc", JSB_ccDrawArc, 6, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 13 | JS_DefineFunction(_cx, cocos2d, "drawCardinalSpline", JSB_ccDrawCardinalSpline, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 14 | JS_DefineFunction(_cx, cocos2d, "drawCatmullRom", JSB_ccDrawCatmullRom, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 15 | JS_DefineFunction(_cx, cocos2d, "drawCircle", JSB_ccDrawCircle, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 16 | JS_DefineFunction(_cx, cocos2d, "drawColor4B", JSB_ccDrawColor4B, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 17 | JS_DefineFunction(_cx, cocos2d, "drawColor4F", JSB_ccDrawColor4F, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 18 | JS_DefineFunction(_cx, cocos2d, "drawCubicBezier", JSB_ccDrawCubicBezier, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 19 | JS_DefineFunction(_cx, cocos2d, "drawFree", JSB_ccDrawFree, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 20 | JS_DefineFunction(_cx, cocos2d, "drawInit", JSB_ccDrawInit, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 21 | JS_DefineFunction(_cx, cocos2d, "drawLine", JSB_ccDrawLine, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 22 | JS_DefineFunction(_cx, cocos2d, "drawPoint", JSB_ccDrawPoint, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 23 | JS_DefineFunction(_cx, cocos2d, "drawQuadBezier", JSB_ccDrawQuadBezier, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 24 | JS_DefineFunction(_cx, cocos2d, "drawRect", JSB_ccDrawRect, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 25 | JS_DefineFunction(_cx, cocos2d, "drawSolidArc", JSB_ccDrawSolidArc, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 26 | JS_DefineFunction(_cx, cocos2d, "drawSolidCircle", JSB_ccDrawSolidCircle, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 27 | JS_DefineFunction(_cx, cocos2d, "drawSolidRect", JSB_ccDrawSolidRect, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 28 | JS_DefineFunction(_cx, cocos2d, "glBindTexture", JSB_ccGLBindTexture, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 29 | JS_DefineFunction(_cx, cocos2d, "glBindTexture2D", JSB_ccGLBindTexture2D, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 30 | JS_DefineFunction(_cx, cocos2d, "glBindTexture2DN", JSB_ccGLBindTexture2DN, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 31 | JS_DefineFunction(_cx, cocos2d, "glBindVAO", JSB_ccGLBindVAO, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 32 | JS_DefineFunction(_cx, cocos2d, "glBlendFunc", JSB_ccGLBlendFunc, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 33 | JS_DefineFunction(_cx, cocos2d, "glBlendResetToCache", JSB_ccGLBlendResetToCache, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 34 | JS_DefineFunction(_cx, cocos2d, "glDeleteProgram", JSB_ccGLDeleteProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 35 | JS_DefineFunction(_cx, cocos2d, "glDeleteTexture", JSB_ccGLDeleteTexture, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 36 | JS_DefineFunction(_cx, cocos2d, "glDeleteTextureN", JSB_ccGLDeleteTextureN, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 37 | JS_DefineFunction(_cx, cocos2d, "glEnable", JSB_ccGLEnable, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 38 | JS_DefineFunction(_cx, cocos2d, "glEnableVertexAttribs", JSB_ccGLEnableVertexAttribs, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 39 | JS_DefineFunction(_cx, cocos2d, "glInvalidateStateCache", JSB_ccGLInvalidateStateCache, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 40 | JS_DefineFunction(_cx, cocos2d, "glUseProgram", JSB_ccGLUseProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 41 | JS_DefineFunction(_cx, cocos2d, "nextPOT", JSB_ccNextPOT, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 42 | JS_DefineFunction(_cx, cocos2d, "pointSize", JSB_ccPointSize, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 43 | JS_DefineFunction(_cx, cocos2d, "setProjectionMatrixDirty", JSB_ccSetProjectionMatrixDirty, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 44 | JS_DefineFunction(_cx, cocos2d, "_fps_images_hd_len", JSB_cc_fps_images_hd_len, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 45 | JS_DefineFunction(_cx, cocos2d, "_fps_images_ipadhd_len", JSB_cc_fps_images_ipadhd_len, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 46 | JS_DefineFunction(_cx, cocos2d, "_fps_images_len", JSB_cc_fps_images_len, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 47 | JS_DefineFunction(_cx, cocos2d, "c4BFromccc4F", JSB_ccc4BFromccc4F, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 48 | JS_DefineFunction(_cx, cocos2d, "c4FEqual", JSB_ccc4FEqual, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 49 | JS_DefineFunction(_cx, cocos2d, "c4FFromccc3B", JSB_ccc4FFromccc3B, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 50 | JS_DefineFunction(_cx, cocos2d, "c4FFromccc4B", JSB_ccc4FFromccc4B, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 51 | JS_DefineFunction(_cx, cocos2d, "_native_p", JSB_ccp, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 52 | JS_DefineFunction(_cx, cocos2d, "pAdd", JSB_ccpAdd, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 53 | JS_DefineFunction(_cx, cocos2d, "pAngle", JSB_ccpAngle, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 54 | JS_DefineFunction(_cx, cocos2d, "pAngleSigned", JSB_ccpAngleSigned, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 55 | JS_DefineFunction(_cx, cocos2d, "pClamp", JSB_ccpClamp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 56 | JS_DefineFunction(_cx, cocos2d, "pCompMult", JSB_ccpCompMult, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 57 | JS_DefineFunction(_cx, cocos2d, "pCross", JSB_ccpCross, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 58 | JS_DefineFunction(_cx, cocos2d, "pDistance", JSB_ccpDistance, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 59 | JS_DefineFunction(_cx, cocos2d, "pDistanceSQ", JSB_ccpDistanceSQ, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 60 | JS_DefineFunction(_cx, cocos2d, "pDot", JSB_ccpDot, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 61 | JS_DefineFunction(_cx, cocos2d, "pForAngle", JSB_ccpForAngle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 62 | JS_DefineFunction(_cx, cocos2d, "pFromSize", JSB_ccpFromSize, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 63 | JS_DefineFunction(_cx, cocos2d, "pFuzzyEqual", JSB_ccpFuzzyEqual, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 64 | JS_DefineFunction(_cx, cocos2d, "pIntersectPoint", JSB_ccpIntersectPoint, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 65 | JS_DefineFunction(_cx, cocos2d, "pLength", JSB_ccpLength, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 66 | JS_DefineFunction(_cx, cocos2d, "pLengthSQ", JSB_ccpLengthSQ, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 67 | JS_DefineFunction(_cx, cocos2d, "pLerp", JSB_ccpLerp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 68 | JS_DefineFunction(_cx, cocos2d, "pMidpoint", JSB_ccpMidpoint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 69 | JS_DefineFunction(_cx, cocos2d, "pMult", JSB_ccpMult, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 70 | JS_DefineFunction(_cx, cocos2d, "pNeg", JSB_ccpNeg, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 71 | JS_DefineFunction(_cx, cocos2d, "pNormalize", JSB_ccpNormalize, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 72 | JS_DefineFunction(_cx, cocos2d, "pPerp", JSB_ccpPerp, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 73 | JS_DefineFunction(_cx, cocos2d, "pProject", JSB_ccpProject, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 74 | JS_DefineFunction(_cx, cocos2d, "pRPerp", JSB_ccpRPerp, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 75 | JS_DefineFunction(_cx, cocos2d, "pRotate", JSB_ccpRotate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 76 | JS_DefineFunction(_cx, cocos2d, "pRotateByAngle", JSB_ccpRotateByAngle, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 77 | JS_DefineFunction(_cx, cocos2d, "pSegmentIntersect", JSB_ccpSegmentIntersect, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 78 | JS_DefineFunction(_cx, cocos2d, "pSub", JSB_ccpSub, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 79 | JS_DefineFunction(_cx, cocos2d, "pToAngle", JSB_ccpToAngle, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 80 | JS_DefineFunction(_cx, cocos2d, "pUnrotate", JSB_ccpUnrotate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 81 | 82 | 83 | #endif // JSB_INCLUDE_COCOS2D 84 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_ios_classes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D_IOS 8 | 9 | #import "jsb_cocos2d_classes.h" 10 | 11 | /* 12 | * CCDirector 13 | */ 14 | #pragma mark - CCDirector 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | void JSB_CCDirector_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 21 | 22 | // Manually generated methods 23 | 24 | 25 | extern JSObject *JSB_CCDirector_object; 26 | extern JSClass *JSB_CCDirector_class; 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | /* Proxy class */ 33 | @interface JSB_CCDirector : JSB_NSObject 34 | { 35 | } 36 | @end 37 | 38 | /* 39 | * CCDirectorIOS 40 | */ 41 | #pragma mark - CCDirectorIOS 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | void JSB_CCDirectorIOS_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 48 | 49 | // Manually generated methods 50 | 51 | 52 | extern JSObject *JSB_CCDirectorIOS_object; 53 | extern JSClass *JSB_CCDirectorIOS_class; 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | /* Proxy class */ 60 | @interface JSB_CCDirectorIOS : JSB_CCDirector 61 | { 62 | } 63 | @end 64 | 65 | /* 66 | * CCDirectorDisplayLink 67 | */ 68 | #pragma mark - CCDirectorDisplayLink 69 | 70 | #ifdef __cplusplus 71 | extern "C" { 72 | #endif 73 | 74 | void JSB_CCDirectorDisplayLink_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 75 | 76 | // Manually generated methods 77 | 78 | 79 | extern JSObject *JSB_CCDirectorDisplayLink_object; 80 | extern JSClass *JSB_CCDirectorDisplayLink_class; 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | /* Proxy class */ 87 | @interface JSB_CCDirectorDisplayLink : JSB_CCDirectorIOS 88 | { 89 | } 90 | @end 91 | 92 | /* 93 | * CCLayer 94 | */ 95 | #pragma mark - CCLayer 96 | 97 | #ifdef __cplusplus 98 | extern "C" { 99 | #endif 100 | 101 | void JSB_CCLayer_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 102 | 103 | // Manually generated methods 104 | 105 | 106 | extern JSObject *JSB_CCLayer_object; 107 | extern JSClass *JSB_CCLayer_class; 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | /* Proxy class */ 114 | @interface JSB_CCLayer : JSB_CCNode 115 | { 116 | } 117 | @end 118 | 119 | /* Manually generated callbacks */ 120 | @interface JSB_CCLayer (Manual) 121 | -(void) accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration ; 122 | 123 | @end 124 | 125 | /* 126 | * CCLayerMultiplex 127 | */ 128 | #pragma mark - CCLayerMultiplex 129 | 130 | #ifdef __cplusplus 131 | extern "C" { 132 | #endif 133 | 134 | void JSB_CCLayerMultiplex_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 135 | 136 | // Manually generated methods 137 | 138 | 139 | extern JSObject *JSB_CCLayerMultiplex_object; 140 | extern JSClass *JSB_CCLayerMultiplex_class; 141 | 142 | #ifdef __cplusplus 143 | } 144 | #endif 145 | 146 | /* Proxy class */ 147 | @interface JSB_CCLayerMultiplex : JSB_CCLayer 148 | { 149 | } 150 | @end 151 | 152 | /* 153 | * CCLayerRGBA 154 | */ 155 | #pragma mark - CCLayerRGBA 156 | 157 | #ifdef __cplusplus 158 | extern "C" { 159 | #endif 160 | 161 | void JSB_CCLayerRGBA_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 162 | 163 | // Manually generated methods 164 | 165 | 166 | extern JSObject *JSB_CCLayerRGBA_object; 167 | extern JSClass *JSB_CCLayerRGBA_class; 168 | 169 | #ifdef __cplusplus 170 | } 171 | #endif 172 | 173 | /* Proxy class */ 174 | @interface JSB_CCLayerRGBA : JSB_CCLayer 175 | { 176 | } 177 | @end 178 | 179 | /* 180 | * CCLayerColor 181 | */ 182 | #pragma mark - CCLayerColor 183 | 184 | #ifdef __cplusplus 185 | extern "C" { 186 | #endif 187 | 188 | void JSB_CCLayerColor_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 189 | 190 | // Manually generated methods 191 | JSBool JSB_CCLayerColor_setBlendFunc_(JSContext *cx, uint32_t argc, jsval *vp); 192 | 193 | 194 | extern JSObject *JSB_CCLayerColor_object; 195 | extern JSClass *JSB_CCLayerColor_class; 196 | 197 | #ifdef __cplusplus 198 | } 199 | #endif 200 | 201 | /* Proxy class */ 202 | @interface JSB_CCLayerColor : JSB_CCLayerRGBA 203 | { 204 | } 205 | @end 206 | 207 | /* 208 | * CCLayerGradient 209 | */ 210 | #pragma mark - CCLayerGradient 211 | 212 | #ifdef __cplusplus 213 | extern "C" { 214 | #endif 215 | 216 | void JSB_CCLayerGradient_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 217 | 218 | // Manually generated methods 219 | 220 | 221 | extern JSObject *JSB_CCLayerGradient_object; 222 | extern JSClass *JSB_CCLayerGradient_class; 223 | 224 | #ifdef __cplusplus 225 | } 226 | #endif 227 | 228 | /* Proxy class */ 229 | @interface JSB_CCLayerGradient : JSB_CCLayerColor 230 | { 231 | } 232 | @end 233 | 234 | /* 235 | * CCMenu 236 | */ 237 | #pragma mark - CCMenu 238 | 239 | #ifdef __cplusplus 240 | extern "C" { 241 | #endif 242 | 243 | void JSB_CCMenu_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 244 | 245 | // Manually generated methods 246 | 247 | 248 | extern JSObject *JSB_CCMenu_object; 249 | extern JSClass *JSB_CCMenu_class; 250 | 251 | #ifdef __cplusplus 252 | } 253 | #endif 254 | 255 | /* Proxy class */ 256 | @interface JSB_CCMenu : JSB_CCLayerRGBA 257 | { 258 | } 259 | @end 260 | 261 | 262 | #endif // JSB_INCLUDE_COCOS2D_IOS 263 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_ios_classes_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D_IOS 8 | 9 | #import "jsb_cocos2d_classes.h" 10 | JSB_CCDirector_createClass(_cx, cocos2d_ios, "Director"); 11 | JSB_CCDirectorIOS_createClass(_cx, cocos2d_ios, "DirectorIOS"); 12 | JSB_CCDirectorDisplayLink_createClass(_cx, cocos2d_ios, "DirectorDisplayLink"); 13 | JSB_CCLayer_createClass(_cx, cocos2d_ios, "Layer"); 14 | JSB_CCLayerRGBA_createClass(_cx, cocos2d_ios, "LayerRGBA"); 15 | JSB_CCLayerColor_createClass(_cx, cocos2d_ios, "LayerColor"); 16 | JSB_CCLayerMultiplex_createClass(_cx, cocos2d_ios, "LayerMultiplex"); 17 | JSB_CCLayerGradient_createClass(_cx, cocos2d_ios, "LayerGradient"); 18 | JSB_CCMenu_createClass(_cx, cocos2d_ios, "Menu"); 19 | 20 | 21 | #endif // JSB_INCLUDE_COCOS2D_IOS 22 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_ios_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D_IOS 8 | 9 | #import "jsb_cocos2d_classes.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | 20 | #endif // JSB_INCLUDE_COCOS2D_IOS 21 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_ios_functions.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D_IOS 8 | 9 | #import "jsb_cocos2d_classes.h" 10 | 11 | #import "jsfriendapi.h" 12 | #import "jsb_config.h" 13 | #import "jsb_core.h" 14 | #import "jsb_basic_conversions.h" 15 | #import "jsb_cocos2d_ios_functions.h" 16 | 17 | 18 | #endif // JSB_INCLUDE_COCOS2D_IOS 19 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_ios_functions_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D_IOS 8 | 9 | #import "jsb_cocos2d_classes.h" 10 | 11 | 12 | #endif // JSB_INCLUDE_COCOS2D_IOS 13 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_mac_classes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D_MAC 8 | 9 | #import "jsb_cocos2d_classes.h" 10 | 11 | /* 12 | * CCDirector 13 | */ 14 | #pragma mark - CCDirector 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | void JSB_CCDirector_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 21 | 22 | // Manually generated methods 23 | 24 | 25 | extern JSObject *JSB_CCDirector_object; 26 | extern JSClass *JSB_CCDirector_class; 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | /* Proxy class */ 33 | @interface JSB_CCDirector : JSB_NSObject 34 | { 35 | } 36 | @end 37 | 38 | /* 39 | * CCDirectorMac 40 | */ 41 | #pragma mark - CCDirectorMac 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | void JSB_CCDirectorMac_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 48 | 49 | // Manually generated methods 50 | 51 | 52 | extern JSObject *JSB_CCDirectorMac_object; 53 | extern JSClass *JSB_CCDirectorMac_class; 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | /* Proxy class */ 60 | @interface JSB_CCDirectorMac : JSB_CCDirector 61 | { 62 | } 63 | @end 64 | 65 | /* 66 | * CCLayer 67 | */ 68 | #pragma mark - CCLayer 69 | 70 | #ifdef __cplusplus 71 | extern "C" { 72 | #endif 73 | 74 | void JSB_CCLayer_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 75 | 76 | // Manually generated methods 77 | 78 | 79 | extern JSObject *JSB_CCLayer_object; 80 | extern JSClass *JSB_CCLayer_class; 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | /* Proxy class */ 87 | @interface JSB_CCLayer : JSB_CCNode 88 | { 89 | } 90 | @end 91 | 92 | /* Manually generated callbacks */ 93 | @interface JSB_CCLayer (Manual) 94 | -(BOOL) ccKeyDown:(NSEvent*)event ; 95 | -(BOOL) ccKeyUp:(NSEvent*)event ; 96 | -(BOOL) ccFlagsChanged:(NSEvent*)event ; 97 | 98 | @end 99 | 100 | /* 101 | * CCLayerMultiplex 102 | */ 103 | #pragma mark - CCLayerMultiplex 104 | 105 | #ifdef __cplusplus 106 | extern "C" { 107 | #endif 108 | 109 | void JSB_CCLayerMultiplex_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 110 | 111 | // Manually generated methods 112 | 113 | 114 | extern JSObject *JSB_CCLayerMultiplex_object; 115 | extern JSClass *JSB_CCLayerMultiplex_class; 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | /* Proxy class */ 122 | @interface JSB_CCLayerMultiplex : JSB_CCLayer 123 | { 124 | } 125 | @end 126 | 127 | /* 128 | * CCLayerRGBA 129 | */ 130 | #pragma mark - CCLayerRGBA 131 | 132 | #ifdef __cplusplus 133 | extern "C" { 134 | #endif 135 | 136 | void JSB_CCLayerRGBA_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 137 | 138 | // Manually generated methods 139 | 140 | 141 | extern JSObject *JSB_CCLayerRGBA_object; 142 | extern JSClass *JSB_CCLayerRGBA_class; 143 | 144 | #ifdef __cplusplus 145 | } 146 | #endif 147 | 148 | /* Proxy class */ 149 | @interface JSB_CCLayerRGBA : JSB_CCLayer 150 | { 151 | } 152 | @end 153 | 154 | /* 155 | * CCLayerColor 156 | */ 157 | #pragma mark - CCLayerColor 158 | 159 | #ifdef __cplusplus 160 | extern "C" { 161 | #endif 162 | 163 | void JSB_CCLayerColor_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 164 | 165 | // Manually generated methods 166 | JSBool JSB_CCLayerColor_setBlendFunc_(JSContext *cx, uint32_t argc, jsval *vp); 167 | 168 | 169 | extern JSObject *JSB_CCLayerColor_object; 170 | extern JSClass *JSB_CCLayerColor_class; 171 | 172 | #ifdef __cplusplus 173 | } 174 | #endif 175 | 176 | /* Proxy class */ 177 | @interface JSB_CCLayerColor : JSB_CCLayerRGBA 178 | { 179 | } 180 | @end 181 | 182 | /* 183 | * CCLayerGradient 184 | */ 185 | #pragma mark - CCLayerGradient 186 | 187 | #ifdef __cplusplus 188 | extern "C" { 189 | #endif 190 | 191 | void JSB_CCLayerGradient_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 192 | 193 | // Manually generated methods 194 | 195 | 196 | extern JSObject *JSB_CCLayerGradient_object; 197 | extern JSClass *JSB_CCLayerGradient_class; 198 | 199 | #ifdef __cplusplus 200 | } 201 | #endif 202 | 203 | /* Proxy class */ 204 | @interface JSB_CCLayerGradient : JSB_CCLayerColor 205 | { 206 | } 207 | @end 208 | 209 | /* 210 | * CCMenu 211 | */ 212 | #pragma mark - CCMenu 213 | 214 | #ifdef __cplusplus 215 | extern "C" { 216 | #endif 217 | 218 | void JSB_CCMenu_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 219 | 220 | // Manually generated methods 221 | 222 | 223 | extern JSObject *JSB_CCMenu_object; 224 | extern JSClass *JSB_CCMenu_class; 225 | 226 | #ifdef __cplusplus 227 | } 228 | #endif 229 | 230 | /* Proxy class */ 231 | @interface JSB_CCMenu : JSB_CCLayerRGBA 232 | { 233 | } 234 | @end 235 | 236 | 237 | #endif // JSB_INCLUDE_COCOS2D_MAC 238 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_mac_classes_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D_MAC 8 | 9 | #import "jsb_cocos2d_classes.h" 10 | JSB_CCDirector_createClass(_cx, cocos2d_mac, "Director"); 11 | JSB_CCLayer_createClass(_cx, cocos2d_mac, "Layer"); 12 | JSB_CCDirectorMac_createClass(_cx, cocos2d_mac, "DirectorMac"); 13 | JSB_CCLayerMultiplex_createClass(_cx, cocos2d_mac, "LayerMultiplex"); 14 | JSB_CCLayerRGBA_createClass(_cx, cocos2d_mac, "LayerRGBA"); 15 | JSB_CCLayerColor_createClass(_cx, cocos2d_mac, "LayerColor"); 16 | JSB_CCLayerGradient_createClass(_cx, cocos2d_mac, "LayerGradient"); 17 | JSB_CCMenu_createClass(_cx, cocos2d_mac, "Menu"); 18 | 19 | 20 | #endif // JSB_INCLUDE_COCOS2D_MAC 21 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_mac_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D_MAC 8 | 9 | #import "jsb_cocos2d_classes.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | 20 | #endif // JSB_INCLUDE_COCOS2D_MAC 21 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_mac_functions.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D_MAC 8 | 9 | #import "jsb_cocos2d_classes.h" 10 | 11 | #import "jsfriendapi.h" 12 | #import "jsb_config.h" 13 | #import "jsb_core.h" 14 | #import "jsb_basic_conversions.h" 15 | #import "jsb_cocos2d_mac_functions.h" 16 | 17 | 18 | #endif // JSB_INCLUDE_COCOS2D_MAC 19 | -------------------------------------------------------------------------------- /src/auto/jsb_cocos2d_mac_functions_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | #import "jsb_config.h" 7 | #if JSB_INCLUDE_COCOS2D_MAC 8 | 9 | #import "jsb_cocos2d_classes.h" 10 | 11 | 12 | #endif // JSB_INCLUDE_COCOS2D_MAC 13 | -------------------------------------------------------------------------------- /src/auto/jsb_opengl_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c opengl_jsb.ini" on 2013-03-18 4 | * Script version: v0.6 5 | */ 6 | #include "jsb_config.h" 7 | #if JSB_INCLUDE_OPENGL 8 | 9 | #include "jsb_opengl_manual.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | JSBool JSB_glActiveTexture(JSContext *cx, uint32_t argc, jsval *vp); 15 | JSBool JSB_glAttachShader(JSContext *cx, uint32_t argc, jsval *vp); 16 | JSBool JSB_glBindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp); 17 | JSBool JSB_glBindBuffer(JSContext *cx, uint32_t argc, jsval *vp); 18 | JSBool JSB_glBindFramebuffer(JSContext *cx, uint32_t argc, jsval *vp); 19 | JSBool JSB_glBindRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); 20 | JSBool JSB_glBindTexture(JSContext *cx, uint32_t argc, jsval *vp); 21 | JSBool JSB_glBlendColor(JSContext *cx, uint32_t argc, jsval *vp); 22 | JSBool JSB_glBlendEquation(JSContext *cx, uint32_t argc, jsval *vp); 23 | JSBool JSB_glBlendEquationSeparate(JSContext *cx, uint32_t argc, jsval *vp); 24 | JSBool JSB_glBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); 25 | JSBool JSB_glBlendFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp); 26 | JSBool JSB_glBufferData(JSContext *cx, uint32_t argc, jsval *vp); 27 | JSBool JSB_glBufferSubData(JSContext *cx, uint32_t argc, jsval *vp); 28 | JSBool JSB_glCheckFramebufferStatus(JSContext *cx, uint32_t argc, jsval *vp); 29 | JSBool JSB_glClear(JSContext *cx, uint32_t argc, jsval *vp); 30 | JSBool JSB_glClearColor(JSContext *cx, uint32_t argc, jsval *vp); 31 | JSBool JSB_glClearDepthf(JSContext *cx, uint32_t argc, jsval *vp); 32 | JSBool JSB_glClearStencil(JSContext *cx, uint32_t argc, jsval *vp); 33 | JSBool JSB_glColorMask(JSContext *cx, uint32_t argc, jsval *vp); 34 | JSBool JSB_glCompileShader(JSContext *cx, uint32_t argc, jsval *vp); 35 | JSBool JSB_glCompressedTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); 36 | JSBool JSB_glCompressedTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); 37 | JSBool JSB_glCopyTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); 38 | JSBool JSB_glCopyTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); 39 | JSBool JSB_glCreateProgram(JSContext *cx, uint32_t argc, jsval *vp); 40 | JSBool JSB_glCreateShader(JSContext *cx, uint32_t argc, jsval *vp); 41 | JSBool JSB_glCullFace(JSContext *cx, uint32_t argc, jsval *vp); 42 | JSBool JSB_glDeleteBuffers(JSContext *cx, uint32_t argc, jsval *vp); 43 | JSBool JSB_glDeleteFramebuffers(JSContext *cx, uint32_t argc, jsval *vp); 44 | JSBool JSB_glDeleteProgram(JSContext *cx, uint32_t argc, jsval *vp); 45 | JSBool JSB_glDeleteRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp); 46 | JSBool JSB_glDeleteShader(JSContext *cx, uint32_t argc, jsval *vp); 47 | JSBool JSB_glDeleteTextures(JSContext *cx, uint32_t argc, jsval *vp); 48 | JSBool JSB_glDepthFunc(JSContext *cx, uint32_t argc, jsval *vp); 49 | JSBool JSB_glDepthMask(JSContext *cx, uint32_t argc, jsval *vp); 50 | JSBool JSB_glDepthRangef(JSContext *cx, uint32_t argc, jsval *vp); 51 | JSBool JSB_glDetachShader(JSContext *cx, uint32_t argc, jsval *vp); 52 | JSBool JSB_glDisable(JSContext *cx, uint32_t argc, jsval *vp); 53 | JSBool JSB_glDisableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp); 54 | JSBool JSB_glDrawArrays(JSContext *cx, uint32_t argc, jsval *vp); 55 | JSBool JSB_glDrawElements(JSContext *cx, uint32_t argc, jsval *vp); 56 | JSBool JSB_glEnable(JSContext *cx, uint32_t argc, jsval *vp); 57 | JSBool JSB_glEnableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp); 58 | JSBool JSB_glFinish(JSContext *cx, uint32_t argc, jsval *vp); 59 | JSBool JSB_glFlush(JSContext *cx, uint32_t argc, jsval *vp); 60 | JSBool JSB_glFramebufferRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); 61 | JSBool JSB_glFramebufferTexture2D(JSContext *cx, uint32_t argc, jsval *vp); 62 | JSBool JSB_glFrontFace(JSContext *cx, uint32_t argc, jsval *vp); 63 | JSBool JSB_glGenBuffers(JSContext *cx, uint32_t argc, jsval *vp); 64 | JSBool JSB_glGenFramebuffers(JSContext *cx, uint32_t argc, jsval *vp); 65 | JSBool JSB_glGenRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp); 66 | JSBool JSB_glGenTextures(JSContext *cx, uint32_t argc, jsval *vp); 67 | JSBool JSB_glGenerateMipmap(JSContext *cx, uint32_t argc, jsval *vp); 68 | JSBool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp); 69 | JSBool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp); 70 | JSBool JSB_glGetAttachedShaders(JSContext *cx, uint32_t argc, jsval *vp); 71 | JSBool JSB_glGetAttribLocation(JSContext *cx, uint32_t argc, jsval *vp); 72 | JSBool JSB_glGetError(JSContext *cx, uint32_t argc, jsval *vp); 73 | JSBool JSB_glGetProgramInfoLog(JSContext *cx, uint32_t argc, jsval *vp); 74 | JSBool JSB_glGetProgramiv(JSContext *cx, uint32_t argc, jsval *vp); 75 | JSBool JSB_glGetShaderInfoLog(JSContext *cx, uint32_t argc, jsval *vp); 76 | JSBool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp); 77 | JSBool JSB_glGetShaderiv(JSContext *cx, uint32_t argc, jsval *vp); 78 | JSBool JSB_glGetTexParameterfv(JSContext *cx, uint32_t argc, jsval *vp); 79 | JSBool JSB_glGetUniformLocation(JSContext *cx, uint32_t argc, jsval *vp); 80 | JSBool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp); 81 | JSBool JSB_glHint(JSContext *cx, uint32_t argc, jsval *vp); 82 | JSBool JSB_glIsBuffer(JSContext *cx, uint32_t argc, jsval *vp); 83 | JSBool JSB_glIsEnabled(JSContext *cx, uint32_t argc, jsval *vp); 84 | JSBool JSB_glIsFramebuffer(JSContext *cx, uint32_t argc, jsval *vp); 85 | JSBool JSB_glIsProgram(JSContext *cx, uint32_t argc, jsval *vp); 86 | JSBool JSB_glIsRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); 87 | JSBool JSB_glIsShader(JSContext *cx, uint32_t argc, jsval *vp); 88 | JSBool JSB_glIsTexture(JSContext *cx, uint32_t argc, jsval *vp); 89 | JSBool JSB_glLineWidth(JSContext *cx, uint32_t argc, jsval *vp); 90 | JSBool JSB_glLinkProgram(JSContext *cx, uint32_t argc, jsval *vp); 91 | JSBool JSB_glPixelStorei(JSContext *cx, uint32_t argc, jsval *vp); 92 | JSBool JSB_glPolygonOffset(JSContext *cx, uint32_t argc, jsval *vp); 93 | JSBool JSB_glReadPixels(JSContext *cx, uint32_t argc, jsval *vp); 94 | JSBool JSB_glReleaseShaderCompiler(JSContext *cx, uint32_t argc, jsval *vp); 95 | JSBool JSB_glRenderbufferStorage(JSContext *cx, uint32_t argc, jsval *vp); 96 | JSBool JSB_glSampleCoverage(JSContext *cx, uint32_t argc, jsval *vp); 97 | JSBool JSB_glScissor(JSContext *cx, uint32_t argc, jsval *vp); 98 | JSBool JSB_glShaderSource(JSContext *cx, uint32_t argc, jsval *vp); 99 | JSBool JSB_glStencilFunc(JSContext *cx, uint32_t argc, jsval *vp); 100 | JSBool JSB_glStencilFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp); 101 | JSBool JSB_glStencilMask(JSContext *cx, uint32_t argc, jsval *vp); 102 | JSBool JSB_glStencilMaskSeparate(JSContext *cx, uint32_t argc, jsval *vp); 103 | JSBool JSB_glStencilOp(JSContext *cx, uint32_t argc, jsval *vp); 104 | JSBool JSB_glStencilOpSeparate(JSContext *cx, uint32_t argc, jsval *vp); 105 | JSBool JSB_glTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); 106 | JSBool JSB_glTexParameterf(JSContext *cx, uint32_t argc, jsval *vp); 107 | JSBool JSB_glTexParameteri(JSContext *cx, uint32_t argc, jsval *vp); 108 | JSBool JSB_glTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); 109 | JSBool JSB_glUniform1f(JSContext *cx, uint32_t argc, jsval *vp); 110 | JSBool JSB_glUniform1fv(JSContext *cx, uint32_t argc, jsval *vp); 111 | JSBool JSB_glUniform1i(JSContext *cx, uint32_t argc, jsval *vp); 112 | JSBool JSB_glUniform1iv(JSContext *cx, uint32_t argc, jsval *vp); 113 | JSBool JSB_glUniform2f(JSContext *cx, uint32_t argc, jsval *vp); 114 | JSBool JSB_glUniform2fv(JSContext *cx, uint32_t argc, jsval *vp); 115 | JSBool JSB_glUniform2i(JSContext *cx, uint32_t argc, jsval *vp); 116 | JSBool JSB_glUniform2iv(JSContext *cx, uint32_t argc, jsval *vp); 117 | JSBool JSB_glUniform3f(JSContext *cx, uint32_t argc, jsval *vp); 118 | JSBool JSB_glUniform3fv(JSContext *cx, uint32_t argc, jsval *vp); 119 | JSBool JSB_glUniform3i(JSContext *cx, uint32_t argc, jsval *vp); 120 | JSBool JSB_glUniform3iv(JSContext *cx, uint32_t argc, jsval *vp); 121 | JSBool JSB_glUniform4f(JSContext *cx, uint32_t argc, jsval *vp); 122 | JSBool JSB_glUniform4fv(JSContext *cx, uint32_t argc, jsval *vp); 123 | JSBool JSB_glUniform4i(JSContext *cx, uint32_t argc, jsval *vp); 124 | JSBool JSB_glUniform4iv(JSContext *cx, uint32_t argc, jsval *vp); 125 | JSBool JSB_glUniformMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp); 126 | JSBool JSB_glUniformMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp); 127 | JSBool JSB_glUniformMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp); 128 | JSBool JSB_glUseProgram(JSContext *cx, uint32_t argc, jsval *vp); 129 | JSBool JSB_glValidateProgram(JSContext *cx, uint32_t argc, jsval *vp); 130 | JSBool JSB_glVertexAttrib1f(JSContext *cx, uint32_t argc, jsval *vp); 131 | JSBool JSB_glVertexAttrib1fv(JSContext *cx, uint32_t argc, jsval *vp); 132 | JSBool JSB_glVertexAttrib2f(JSContext *cx, uint32_t argc, jsval *vp); 133 | JSBool JSB_glVertexAttrib2fv(JSContext *cx, uint32_t argc, jsval *vp); 134 | JSBool JSB_glVertexAttrib3f(JSContext *cx, uint32_t argc, jsval *vp); 135 | JSBool JSB_glVertexAttrib3fv(JSContext *cx, uint32_t argc, jsval *vp); 136 | JSBool JSB_glVertexAttrib4f(JSContext *cx, uint32_t argc, jsval *vp); 137 | JSBool JSB_glVertexAttrib4fv(JSContext *cx, uint32_t argc, jsval *vp); 138 | JSBool JSB_glVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp); 139 | JSBool JSB_glViewport(JSContext *cx, uint32_t argc, jsval *vp); 140 | 141 | #ifdef __cplusplus 142 | } 143 | #endif 144 | 145 | 146 | #endif // JSB_INCLUDE_OPENGL 147 | -------------------------------------------------------------------------------- /src/auto/jsb_system_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c system_jsb.ini" on 2013-03-05 4 | * Script version: v0.6 5 | */ 6 | #include "jsb_config.h" 7 | #if JSB_INCLUDE_SYSTEM 8 | 9 | #include "LocalStorage.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | JSBool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp); 15 | JSBool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp); 16 | JSBool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | 23 | #endif // JSB_INCLUDE_SYSTEM 24 | -------------------------------------------------------------------------------- /src/auto/jsb_system_functions.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c system_jsb.ini" on 2013-03-05 4 | * Script version: v0.6 5 | */ 6 | #include "jsb_config.h" 7 | #if JSB_INCLUDE_SYSTEM 8 | 9 | #include "LocalStorage.h" 10 | 11 | #include "jsfriendapi.h" 12 | #include "jsb_config.h" 13 | #include "jsb_core.h" 14 | #include "jsb_basic_conversions.h" 15 | #include "jsb_system_functions.h" 16 | 17 | // Arguments: char* 18 | // Ret value: const char* 19 | JSBool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp) { 20 | JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); 21 | jsval *argvp = JS_ARGV(cx,vp); 22 | JSBool ok = JS_TRUE; 23 | const char* arg0; 24 | 25 | ok &= JSB_jsval_to_charptr( cx, *argvp++, &arg0 ); 26 | JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); 27 | const char* ret_val; 28 | 29 | ret_val = localStorageGetItem((char*)arg0 ); 30 | 31 | jsval ret_jsval = JSB_jsval_from_charptr( cx, ret_val ); 32 | JS_SET_RVAL(cx, vp, ret_jsval ); 33 | 34 | return JS_TRUE; 35 | } 36 | 37 | // Arguments: char* 38 | // Ret value: void 39 | JSBool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp) { 40 | JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); 41 | jsval *argvp = JS_ARGV(cx,vp); 42 | JSBool ok = JS_TRUE; 43 | const char* arg0; 44 | 45 | ok &= JSB_jsval_to_charptr( cx, *argvp++, &arg0 ); 46 | JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); 47 | 48 | localStorageRemoveItem((char*)arg0 ); 49 | JS_SET_RVAL(cx, vp, JSVAL_VOID); 50 | return JS_TRUE; 51 | } 52 | 53 | // Arguments: char*, char* 54 | // Ret value: void 55 | JSBool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp) { 56 | JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); 57 | jsval *argvp = JS_ARGV(cx,vp); 58 | JSBool ok = JS_TRUE; 59 | const char* arg0; const char* arg1; 60 | 61 | ok &= JSB_jsval_to_charptr( cx, *argvp++, &arg0 ); 62 | ok &= JSB_jsval_to_charptr( cx, *argvp++, &arg1 ); 63 | JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); 64 | 65 | localStorageSetItem((char*)arg0 , (char*)arg1 ); 66 | JS_SET_RVAL(cx, vp, JSVAL_VOID); 67 | return JS_TRUE; 68 | } 69 | 70 | 71 | #endif // JSB_INCLUDE_SYSTEM 72 | -------------------------------------------------------------------------------- /src/auto/jsb_system_functions_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c system_jsb.ini" on 2013-03-05 4 | * Script version: v0.6 5 | */ 6 | #include "jsb_config.h" 7 | #if 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 | -------------------------------------------------------------------------------- /src/js/jsb.js: -------------------------------------------------------------------------------- 1 | // 2 | // Javascript Bindigns helper file 3 | // 4 | 5 | // DO NOT ALTER THE ORDER 6 | require('jsb_cocos2d.js'); 7 | require('jsb_chipmunk.js'); 8 | require('jsb_opengl.js'); 9 | require('jsb_cocosbuilder.js'); 10 | require('jsb_sys.js'); 11 | -------------------------------------------------------------------------------- /src/js/jsb_chipmunk.js: -------------------------------------------------------------------------------- 1 | // 2 | // Chipmunk defines 3 | // 4 | 5 | require('jsb_chipmunk_constants.js'); 6 | 7 | var cp = cp || {}; 8 | 9 | cp.v = cc.p; 10 | cp._v = cc._p; 11 | cp.vzero = cp.v(0,0); 12 | 13 | // Vector: Compatibility with Chipmunk-JS 14 | cp.v.add = cp.vadd; 15 | cp.v.clamp = cp.vclamp; 16 | cp.v.cross = cp.vcross; 17 | cp.v.dist = cp.vdist; 18 | cp.v.distsq = cp.vdistsq; 19 | cp.v.dot = cp.vdot; 20 | cp.v.eql = cp.veql; 21 | cp.v.forangle = cp.vforangle; 22 | cp.v.len = cp.vlength; 23 | cp.v.lengthsq = cp.vlengthsq; 24 | cp.v.lerp = cp.vlerp; 25 | cp.v.lerpconst = cp.vlerpconst; 26 | cp.v.mult = cp.vmult; 27 | cp.v.near = cp.vnear; 28 | cp.v.neg = cp.vneg; 29 | cp.v.normalize = cp.vnormalize; 30 | cp.v.normalize_safe = cp.vnormalize_safe; 31 | cp.v.perp = cp.vperp; 32 | cp.v.project = cp.vproject; 33 | cp.v.rotate = cp.vrotate; 34 | cp.v.rperp = cp.vrperp; 35 | cp.v.slerp = cp.vslerp; 36 | cp.v.slerpconst = cp.vslerpconst; 37 | cp.v.sub = cp.vsub; 38 | cp.v.toangle = cp.vtoangle; 39 | cp.v.unrotate = cp.vunrotate; 40 | 41 | // XXX: renaming functions should be supported in JSB 42 | cp.clamp01 = cp.fclamp01; 43 | 44 | 45 | /// Initialize an offset box shaped polygon shape. 46 | cp.BoxShape2 = function(body, box) 47 | { 48 | var verts = [ 49 | box.l, box.b, 50 | box.l, box.t, 51 | box.r, box.t, 52 | box.r, box.b 53 | ]; 54 | 55 | return new cp.PolyShape(body, verts, cp.vzero); 56 | }; 57 | 58 | /// Initialize a box shaped polygon shape. 59 | cp.BoxShape = function(body, width, height) 60 | { 61 | var hw = width/2; 62 | var hh = height/2; 63 | 64 | return cp.BoxShape2(body, new cp.BB(-hw, -hh, hw, hh)); 65 | }; 66 | 67 | 68 | /// Initialize an static body 69 | cp.StaticBody = function() 70 | { 71 | return new cp.Body(Infinity, Infinity); 72 | }; 73 | 74 | 75 | // "Bounding Box" compatibility with Chipmunk-JS 76 | cp.BB = function(l, b, r, t) 77 | { 78 | return {l:l, b:b, r:r, t:t}; 79 | }; 80 | 81 | // helper function to create a BB 82 | cp.bb = function(l, b, r, t) { 83 | return new cp.BB(l, b, r, t); 84 | }; 85 | 86 | // 87 | // Some properties 88 | // 89 | // "handle" needed in some cases 90 | Object.defineProperties(cp.Base.prototype, 91 | { 92 | "handle" : { 93 | get : function(){ 94 | return this.getHandle(); 95 | }, 96 | enumerable : true, 97 | configurable : true 98 | } 99 | }); 100 | 101 | // Properties, for Chipmunk-JS compatibility 102 | // Space properties 103 | Object.defineProperties(cp.Space.prototype, 104 | { 105 | "gravity" : { 106 | get : function(){ 107 | return this.getGravity(); 108 | }, 109 | set : function(newValue){ 110 | this.setGravity(newValue); 111 | }, 112 | enumerable : true, 113 | configurable : true 114 | }, 115 | "iterations" : { 116 | get : function(){ 117 | return this.getIterations(); 118 | }, 119 | set : function(newValue){ 120 | this.setIterations(newValue); 121 | }, 122 | enumerable : true, 123 | configurable : true 124 | }, 125 | "damping" : { 126 | get : function(){ 127 | return this.getDamping(); 128 | }, 129 | set : function(newValue){ 130 | this.setDamping(newValue); 131 | }, 132 | enumerable : true, 133 | configurable : true 134 | }, 135 | "staticBody" : { 136 | get : function(){ 137 | return this.getStaticBody(); 138 | }, 139 | enumerable : true, 140 | configurable : true 141 | }, 142 | "idleSpeedThreshold" : { 143 | get : function(){ 144 | return this.getIdleSpeedThreshold(); 145 | }, 146 | set : function(newValue){ 147 | this.setIdleSpeedThreshold(newValue); 148 | }, 149 | enumerable : true, 150 | configurable : true 151 | }, 152 | "sleepTimeThreshold": { 153 | get : function(){ 154 | return this.getSleepTimeThreshold(); 155 | }, 156 | set : function(newValue){ 157 | this.setSleepTimeThreshold(newValue); 158 | }, 159 | enumerable : true, 160 | configurable : true 161 | }, 162 | "collisionSlop": { 163 | get : function(){ 164 | return this.getCollisionSlop(); 165 | }, 166 | set : function(newValue){ 167 | this.setCollisionSlop(newValue); 168 | }, 169 | enumerable : true, 170 | configurable : true 171 | }, 172 | "collisionBias": { 173 | get : function(){ 174 | return this.getCollisionBias(); 175 | }, 176 | set : function(newValue){ 177 | this.setCollisionBias(newValue); 178 | }, 179 | enumerable : true, 180 | configurable : true 181 | }, 182 | "collisionPersistence": { 183 | get : function(){ 184 | return this.getCollisionPersistence(); 185 | }, 186 | set : function(newValue){ 187 | this.setCollisionPersistence(newValue); 188 | }, 189 | enumerable : true, 190 | configurable : true 191 | }, 192 | "enableContactGraph": { 193 | get : function(){ 194 | return this.getEnableContactGraph(); 195 | }, 196 | set : function(newValue){ 197 | this.setEnableContactGraph(newValue); 198 | }, 199 | enumerable : true, 200 | configurable : true 201 | } 202 | }); 203 | 204 | // Body properties 205 | Object.defineProperties(cp.Body.prototype, 206 | { 207 | "a" : { 208 | get : function(){ 209 | return this.getAngle(); 210 | }, 211 | set : function(newValue){ 212 | this.setAngle(newValue); 213 | }, 214 | enumerable : true, 215 | configurable : true 216 | }, 217 | "w" : { 218 | get : function(){ 219 | return this.getAngVel(); 220 | }, 221 | set : function(newValue){ 222 | this.setAngVel(newValue); 223 | }, 224 | enumerable : true, 225 | configurable : true 226 | }, 227 | "p" : { 228 | get : function(){ 229 | return this.getPos(); 230 | }, 231 | set : function(newValue){ 232 | this.setPos(newValue); 233 | }, 234 | enumerable : true, 235 | configurable : true 236 | }, 237 | "v" : { 238 | get : function(){ 239 | return this.getVel(); 240 | }, 241 | set : function(newValue){ 242 | this.setVel(newValue); 243 | }, 244 | enumerable : true, 245 | configurable : true 246 | }, 247 | "i" : { 248 | get : function(){ 249 | return this.getMoment(); 250 | }, 251 | set : function(newValue){ 252 | this.setMoment(newValue); 253 | }, 254 | enumerable : true, 255 | configurable : true 256 | } 257 | 258 | }); 259 | 260 | // Shape properties 261 | Object.defineProperties(cp.Shape.prototype, 262 | { 263 | "body" : { 264 | get : function(){ 265 | return this.getBody(); 266 | }, 267 | set : function(newValue){ 268 | this.setBody(newValue); 269 | }, 270 | enumerable : true, 271 | configurable : true 272 | }, 273 | "group" : { 274 | get : function(){ 275 | return this.getGroup(); 276 | }, 277 | set : function(newValue){ 278 | this.setGroup(newValue); 279 | }, 280 | enumerable : true, 281 | configurable : true 282 | }, 283 | "collision_type" : { 284 | get : function(){ 285 | return this.getCollisionType(); 286 | }, 287 | enumerable : true, 288 | configurable : true 289 | } 290 | }); 291 | 292 | // Constraint properties 293 | Object.defineProperties(cp.Constraint.prototype, 294 | { 295 | "maxForce" : { 296 | get : function(){ 297 | return this.getMaxForce(); 298 | }, 299 | set : function(newValue){ 300 | this.setMaxForce(newValue); 301 | }, 302 | enumerable : true, 303 | configurable : true 304 | } 305 | }); 306 | 307 | // PinJoint properties 308 | Object.defineProperties(cp.PinJoint.prototype, 309 | { 310 | "anchr1" : { 311 | get : function(){ 312 | return this.getAnchr1(); 313 | }, 314 | set : function(newValue){ 315 | this.setAnchr1(newValue); 316 | }, 317 | enumerable : true, 318 | configurable : true 319 | }, 320 | "anchr2" : { 321 | get : function(){ 322 | return this.getAnchr2(); 323 | }, 324 | set : function(newValue){ 325 | this.setAnchr2(newValue); 326 | }, 327 | enumerable : true, 328 | configurable : true 329 | } 330 | }); 331 | -------------------------------------------------------------------------------- /src/js/jsb_chipmunk_constants.js: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c chipmunk_jsb.ini" on 2013-10-30 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 | -------------------------------------------------------------------------------- /src/js/jsb_cocos2d_constants.js: -------------------------------------------------------------------------------- 1 | /* 2 | * AUTOGENERATED FILE. DO NOT EDIT IT 3 | * Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-10-31 4 | * Script version: v0.6 5 | */ 6 | 7 | var cc = cc || {}; 8 | cc.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff; 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.DIRECTOR_PROJECTION2_D = 0x0; 50 | cc.DIRECTOR_PROJECTION3_D = 0x1; 51 | cc.DIRECTOR_PROJECTION_CUSTOM = 0x2; 52 | cc.DIRECTOR_PROJECTION_DEFAULT = 0x1; 53 | cc.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1; 54 | cc.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0; 55 | cc.FLIPED_ALL = 0xe0000000; 56 | cc.FLIPPED_MASK = 0x1fffffff; 57 | cc.IMAGE_FORMAT_JPEG = 0x0; 58 | cc.IMAGE_FORMAT_PNG = 0x1; 59 | cc.ITEM_SIZE = 0x20; 60 | cc.LABEL_AUTOMATIC_WIDTH = -1; 61 | cc.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1; 62 | cc.LINE_BREAK_MODE_CLIP = 0x2; 63 | cc.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3; 64 | cc.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5; 65 | cc.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4; 66 | cc.LINE_BREAK_MODE_WORD_WRAP = 0x0; 67 | cc.MAC_VERSION_10_6 = 0xa060000; 68 | cc.MAC_VERSION_10_7 = 0xa070000; 69 | cc.MAC_VERSION_10_8 = 0xa080000; 70 | cc.MENU_HANDLER_PRIORITY = -128; 71 | cc.MENU_STATE_TRACKING_TOUCH = 0x1; 72 | cc.MENU_STATE_WAITING = 0x0; 73 | cc.NODE_TAG_INVALID = -1; 74 | cc.PARTICLE_DURATION_INFINITY = -1; 75 | cc.PARTICLE_MODE_GRAVITY = 0x0; 76 | cc.PARTICLE_MODE_RADIUS = 0x1; 77 | cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1; 78 | cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1; 79 | cc.POSITION_TYPE_FREE = 0x0; 80 | cc.POSITION_TYPE_GROUPED = 0x2; 81 | cc.POSITION_TYPE_RELATIVE = 0x1; 82 | cc.PRIORITY_NON_SYSTEM_MIN = -2147483647; 83 | cc.PRIORITY_SYSTEM = -2147483648; 84 | cc.PROGRESS_TIMER_TYPE_BAR = 0x1; 85 | cc.PROGRESS_TIMER_TYPE_RADIAL = 0x0; 86 | cc.REPEAT_FOREVER = 0xfffffffe; 87 | cc.RESOLUTION_MAC = 0x1; 88 | cc.RESOLUTION_MAC_RETINA_DISPLAY = 0x2; 89 | cc.RESOLUTION_UNKNOWN = 0x0; 90 | cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000; 91 | cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000; 92 | cc.TMX_TILE_VERTICAL_FLAG = 0x40000000; 93 | cc.TEXT_ALIGNMENT_CENTER = 0x1; 94 | cc.TEXT_ALIGNMENT_LEFT = 0x0; 95 | cc.TEXT_ALIGNMENT_RIGHT = 0x2; 96 | cc.TEXTURE2_D_PIXEL_FORMAT_A8 = 0x3; 97 | cc.TEXTURE2_D_PIXEL_FORMAT_A_I88 = 0x5; 98 | cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT = 0x0; 99 | cc.TEXTURE2_D_PIXEL_FORMAT_I8 = 0x4; 100 | cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2 = 0x9; 101 | cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4 = 0x8; 102 | cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565 = 0x2; 103 | cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1 = 0x7; 104 | cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888 = 0x1; 105 | cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444 = 0x6; 106 | cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888 = 0x0; 107 | cc.TOUCHES_ALL_AT_ONCE = 0x0; 108 | cc.TOUCHES_ONE_BY_ONE = 0x1; 109 | cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1; 110 | cc.TRANSITION_ORIENTATION_LEFT_OVER = 0x0; 111 | cc.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1; 112 | cc.TRANSITION_ORIENTATION_UP_OVER = 0x0; 113 | cc.UNIFORM_COS_TIME = 0x5; 114 | cc.UNIFORM_MV_MATRIX = 0x1; 115 | cc.UNIFORM_MVP_MATRIX = 0x2; 116 | cc.UNIFORM_P_MATRIX = 0x0; 117 | cc.UNIFORM_RANDOM01 = 0x6; 118 | cc.UNIFORM_SAMPLER = 0x7; 119 | cc.UNIFORM_SIN_TIME = 0x4; 120 | cc.UNIFORM_TIME = 0x3; 121 | cc.UNIFORM_MAX = 0x8; 122 | cc.VERTEX_ATTRIB_FLAG_COLOR = 0x2; 123 | cc.VERTEX_ATTRIB_FLAG_NONE = 0x0; 124 | cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = 0x7; 125 | cc.VERTEX_ATTRIB_FLAG_POSITION = 0x1; 126 | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 0x4; 127 | cc.VERTEX_ATTRIB_COLOR = 0x1; 128 | cc.VERTEX_ATTRIB_MAX = 0x3; 129 | cc.VERTEX_ATTRIB_POSITION = 0x0; 130 | cc.VERTEX_ATTRIB_TEX_COORDS = 0x2; 131 | cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2; 132 | cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1; 133 | cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0; 134 | cc.OS_VERSION_4_0 = 0x4000000; 135 | cc.OS_VERSION_4_0_1 = 0x4000100; 136 | cc.OS_VERSION_4_1 = 0x4010000; 137 | cc.OS_VERSION_4_2 = 0x4020000; 138 | cc.OS_VERSION_4_2_1 = 0x4020100; 139 | cc.OS_VERSION_4_3 = 0x4030000; 140 | cc.OS_VERSION_4_3_1 = 0x4030100; 141 | cc.OS_VERSION_4_3_2 = 0x4030200; 142 | cc.OS_VERSION_4_3_3 = 0x4030300; 143 | cc.OS_VERSION_4_3_4 = 0x4030400; 144 | cc.OS_VERSION_4_3_5 = 0x4030500; 145 | cc.OS_VERSION_5_0 = 0x5000000; 146 | cc.OS_VERSION_5_0_1 = 0x5000100; 147 | cc.OS_VERSION_5_1_0 = 0x5010000; 148 | cc.OS_VERSION_6_0_0 = 0x6000000; 149 | cc.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification'; 150 | cc.CHIPMUNK_IMPORT = 'chipmunk.h'; 151 | cc.ATTRIBUTE_NAME_COLOR = 'a_color'; 152 | cc.ATTRIBUTE_NAME_POSITION = 'a_position'; 153 | cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord'; 154 | cc.SHADER_POSITION_COLOR = 'ShaderPositionColor'; 155 | cc.SHADER_POSITION_LENGTH_TEXURE_COLOR = 'ShaderPositionLengthTextureColor'; 156 | cc.SHADER_POSITION_TEXTURE = 'ShaderPositionTexture'; 157 | cc.SHADER_POSITION_TEXTURE_A8_COLOR = 'ShaderPositionTextureA8Color'; 158 | cc.SHADER_POSITION_TEXTURE_COLOR = 'ShaderPositionTextureColor'; 159 | cc.SHADER_POSITION_TEXTURE_COLOR_ALPHA_TEST = 'ShaderPositionTextureColorAlphaTest'; 160 | cc.SHADER_POSITION_TEXTURE_U_COLOR = 'ShaderPositionTexture_uColor'; 161 | cc.SHADER_POSITION_U_COLOR = 'ShaderPosition_uColor'; 162 | cc.UNIFORM_ALPHA_TEST_VALUE_S = 'CC_AlphaValue'; 163 | cc.UNIFORM_COS_TIME_S = 'CC_CosTime'; 164 | cc.UNIFORM_MV_MATRIX_S = 'CC_MVMatrix'; 165 | cc.UNIFORM_MVP_MATRIX_S = 'CC_MVPMatrix'; 166 | cc.UNIFORM_P_MATRIX_S = 'CC_PMatrix'; 167 | cc.UNIFORM_RANDOM01_S = 'CC_Random01'; 168 | cc.UNIFORM_SAMPLER_S = 'CC_Texture0'; 169 | cc.UNIFORM_SIN_TIME_S = 'CC_SinTime'; 170 | cc.UNIFORM_TIME_S = 'CC_Time'; 171 | -------------------------------------------------------------------------------- /src/js/jsb_cocosbuilder.js: -------------------------------------------------------------------------------- 1 | // 2 | // CocosBuilder definitions 3 | // 4 | 5 | cc.BuilderReader = cc.BuilderReader || {}; 6 | 7 | var _ccbGlobalContext = this; 8 | 9 | // Added for CCB HTML5 compatibility 10 | cc.BuilderReader.setResourcePath = function(path){ 11 | cc._Reader.setResourcePath(path); 12 | }; 13 | 14 | cc.BuilderReader.load = function(file, owner, parentSize) 15 | { 16 | // Load the node graph using the correct function 17 | var reader = cc._Reader.create(); 18 | var node; 19 | 20 | if (parentSize) 21 | { 22 | node = reader.load(file, null, parentSize); 23 | } 24 | else 25 | { 26 | node = reader.load(file); 27 | } 28 | 29 | // Assign owner callbacks & member variables 30 | if (owner) 31 | { 32 | // Callbacks 33 | var ownerCallbackNames = reader.getOwnerCallbackNames(); 34 | var ownerCallbackNodes = reader.getOwnerCallbackNodes(); 35 | 36 | for (var i = 0; i < ownerCallbackNames.length; i++) 37 | { 38 | var callbackName = ownerCallbackNames[i]; 39 | var callbackNode = ownerCallbackNodes[i]; 40 | 41 | callbackNode.setCallback(owner[callbackName], owner); 42 | 43 | } 44 | 45 | // Variables 46 | var ownerOutletNames = reader.getOwnerOutletNames(); 47 | var ownerOutletNodes = reader.getOwnerOutletNodes(); 48 | 49 | for (var i = 0; i < ownerOutletNames.length; i++) 50 | { 51 | var outletName = ownerOutletNames[i]; 52 | var outletNode = ownerOutletNodes[i]; 53 | 54 | owner[outletName] = outletNode; 55 | } 56 | } 57 | 58 | var nodesWithAnimationManagers = reader.getNodesWithAnimationManagers(); 59 | var animationManagersForNodes = reader.getAnimationManagersForNodes(); 60 | 61 | // Attach animation managers to nodes and assign root node callbacks and member variables 62 | for (var i = 0; i < nodesWithAnimationManagers.length; i++) 63 | { 64 | var innerNode = nodesWithAnimationManagers[i]; 65 | var animationManager = animationManagersForNodes[i]; 66 | 67 | innerNode.animationManager = animationManager; 68 | 69 | var documentControllerName = animationManager.getDocumentControllerName(); 70 | if (!documentControllerName) continue; 71 | 72 | // Create a document controller 73 | var controller = new _ccbGlobalContext[documentControllerName](); 74 | controller.controllerName = documentControllerName; 75 | 76 | innerNode.controller = controller; 77 | controller.rootNode = innerNode; 78 | 79 | // Callbacks 80 | var documentCallbackNames = animationManager.getDocumentCallbackNames(); 81 | var documentCallbackNodes = animationManager.getDocumentCallbackNodes(); 82 | 83 | for (var j = 0; j < documentCallbackNames.length; j++) 84 | { 85 | var callbackName = documentCallbackNames[j]; 86 | var callbackNode = documentCallbackNodes[j]; 87 | 88 | callbackNode.setCallback(controller[callbackName], controller); 89 | } 90 | 91 | 92 | // Variables 93 | var documentOutletNames = animationManager.getDocumentOutletNames(); 94 | var documentOutletNodes = animationManager.getDocumentOutletNodes(); 95 | 96 | for (var j = 0; j < documentOutletNames.length; j++) 97 | { 98 | var outletName = documentOutletNames[j]; 99 | var outletNode = documentOutletNodes[j]; 100 | 101 | controller[outletName] = outletNode; 102 | } 103 | 104 | if (typeof(controller.onDidLoadFromCCB) == "function") 105 | { 106 | controller.onDidLoadFromCCB(); 107 | } 108 | 109 | // Setup timeline callbacks 110 | var keyframeCallbacks = animationManager.getKeyframeCallbacks(); 111 | for (var j = 0; j < keyframeCallbacks.length; j++) 112 | { 113 | var callbackSplit = keyframeCallbacks[j].split(":"); 114 | var callbackType = callbackSplit[0]; 115 | var callbackName = callbackSplit[1]; 116 | 117 | if (callbackType == 1) // Document callback 118 | { 119 | var callfunc = cc.CallFunc.create(controller[callbackName], controller); 120 | animationManager.setCallFuncForJSCallbackNamed(callfunc, keyframeCallbacks[j]); 121 | } 122 | else if (callbackType == 2 && owner) // Owner callback 123 | { 124 | var callfunc = cc.CallFunc.create(owner[callbackName], owner); 125 | animationManager.setCallFuncForJSCallbackNamed(callfunc, keyframeCallbacks[j]); 126 | } 127 | } 128 | 129 | // Start animation 130 | var autoPlaySeqId = animationManager.getAutoPlaySequenceId(); 131 | if (autoPlaySeqId != -1) 132 | { 133 | animationManager.runAnimationsForSequenceIdTweenDuration(autoPlaySeqId, 0); 134 | } 135 | } 136 | 137 | return node; 138 | }; 139 | 140 | cc.BuilderReader.loadAsScene = function(file, owner, parentSize) 141 | { 142 | var node = cc.BuilderReader.load(file, owner, parentSize); 143 | var scene = cc.Scene.create(); 144 | scene.addChild( node ); 145 | 146 | return scene; 147 | }; 148 | -------------------------------------------------------------------------------- /src/js/jsb_sys.js: -------------------------------------------------------------------------------- 1 | // 2 | // sys properties 3 | // 4 | 5 | var sys = sys || {}; 6 | 7 | Object.defineProperties(sys, 8 | { 9 | "capabilities" : { 10 | get : function(){ 11 | var capabilities = {"opengl":true}; 12 | if( sys.platform == 'mobile' ) { 13 | capabilities["accelerometer"] = true; 14 | capabilities["touches"] = true; 15 | } else { 16 | // desktop 17 | capabilities["keyboard"] = true; 18 | capabilities["mouse"] = true; 19 | } 20 | return capabilities; 21 | }, 22 | enumerable : true, 23 | configurable : true 24 | }, 25 | "os" : { 26 | get : function(){ 27 | return __getOS(); 28 | }, 29 | enumerable : true, 30 | configurable : true 31 | }, 32 | "platform" : { 33 | get : function(){ 34 | return __getPlatform(); 35 | }, 36 | enumerable : true, 37 | configurable : true 38 | }, 39 | "version" : { 40 | get : function(){ 41 | return __getVersion(); 42 | }, 43 | enumerable : true, 44 | configurable : true 45 | } 46 | 47 | }); 48 | 49 | // Forces the garbage collector 50 | sys.garbageCollect = function() { 51 | __garbageCollect(); 52 | }; 53 | 54 | // Dumps rooted objects 55 | sys.dumpRoot = function() { 56 | __dumpRoot(); 57 | }; 58 | 59 | // restarts the JS VM 60 | sys.restartVM = function() { 61 | __restartVM(); 62 | }; 63 | -------------------------------------------------------------------------------- /src/js/main.example.js: -------------------------------------------------------------------------------- 1 | /** 2 | * bootstrap for the debugger. You can test to see if the debugger is loaded by checking the type of 3 | * `startDebugger`. If that function is defined, then you should call it with the global object, 4 | * which at this point is `this`, the array of files that you need to load (usually is just your 5 | * main javascript), and the function that needs to be called to start your game, as a string. 6 | * If the `startDebugger` function is not defined, then you just require your files and start your 7 | * game :) 8 | */ 9 | var files = ['MoonWarriors-jsb.js']; 10 | if (typeof startDebugger !== "undefined") { 11 | cc.log("**** will start debugger ****"); 12 | startDebugger(this, files); 13 | } else { 14 | cc.log("**** no debugger loaded ****"); 15 | for (var i in files) { 16 | require(files[i]); 17 | } 18 | run(); 19 | } 20 | -------------------------------------------------------------------------------- /src/manual/jsb_CocosBuilderReader_manual.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | #import "jsb_config.h" 26 | 27 | #ifdef JSB_INCLUDE_COCOSBUILDERREADER 28 | 29 | #import "jsb_core.h" 30 | #import "jsb_CocosBuilderReader_classes.h" 31 | #import "jsb_basic_conversions.h" 32 | 33 | // Arguments: void (^)(id) 34 | // Ret value: void (None) 35 | JSBool JSB_CCBAnimationManager_setCompletedAnimationCallbackBlock_(JSContext *cx, uint32_t argc, jsval *vp) { 36 | 37 | JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); 38 | JSB_NSObject *proxy = (JSB_NSObject*) JSB_get_proxy_for_jsobject(jsthis); 39 | 40 | JSB_PRECONDITION( proxy && [proxy realObj], "Invalid Proxy object"); 41 | JSB_PRECONDITION( argc == 2, "Invalid number of arguments. Expecting 2 args" ); 42 | jsval *argvp = JS_ARGV(cx,vp); 43 | js_block js_func; 44 | JSObject *js_this; 45 | JSBool ok = JS_TRUE; 46 | 47 | ok &= JS_ValueToObject(cx, *argvp, &js_this); 48 | ok &= JSB_set_reserved_slot(jsthis, 0, *argvp++ ); 49 | 50 | ok &= JSB_jsval_to_block_1( cx, *argvp, js_this, &js_func ); 51 | ok &= JSB_set_reserved_slot(jsthis, 1, *argvp++ ); 52 | 53 | if( ! ok ) 54 | return JS_FALSE; 55 | 56 | CCBAnimationManager *real = (CCBAnimationManager*) [proxy realObj]; 57 | [real setCompletedAnimationCallbackBlock:(void(^)(id sender))js_func]; 58 | JS_SET_RVAL(cx, vp, JSVAL_VOID); 59 | return JS_TRUE; 60 | } 61 | 62 | #endif // JSB_INCLUDE_COCOSBUILDERREADER 63 | 64 | -------------------------------------------------------------------------------- /src/manual/jsb_NS_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 __JSB_NS_MANUAL_H 26 | #define __JSB_NS_MANUAL_H 27 | 28 | #import "jsb_config.h" 29 | 30 | #ifdef JSB_INCLUDE_NS 31 | 32 | #import "jsb_core.h" 33 | #import "jsb_basic_conversions.h" 34 | 35 | @interface JSB_NSObject : NSObject 36 | { 37 | JSObject *_jsObj; 38 | id _realObj; 39 | Class _klass; 40 | char *_description; 41 | } 42 | 43 | @property (nonatomic, readwrite, assign) JSObject *jsObj; 44 | @property (nonatomic, readwrite, assign) id realObj; 45 | @property (nonatomic, readonly) Class klass; 46 | 47 | +(void) swizzleMethods; 48 | +(JSObject*) createJSObjectWithRealObject:(id)realObj context:(JSContext*)JSContext; 49 | -(id) initWithJSObject:(JSObject*)object class:(Class)klass; 50 | -(void) unrootJSObject; 51 | @end 52 | 53 | 54 | 55 | #ifdef __cplusplus 56 | extern "C" { 57 | #endif 58 | 59 | void JSB_NSObject_createClass(JSContext* cx, JSObject* globalObj, const char * name ); 60 | extern JSObject* JSB_NSObject_object; 61 | extern JSClass* JSB_NSObject_class; 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | 68 | 69 | #ifdef __CC_PLATFORM_MAC 70 | 71 | @interface JSB_NSEvent : JSB_NSObject 72 | { 73 | } 74 | @end 75 | 76 | #ifdef __cplusplus 77 | extern "C" { 78 | #endif 79 | void JSB_NSEvent_createClass(JSContext* cx, JSObject* globalObj, const char * name ); 80 | extern JSObject* JSB_NSEvent_object; 81 | extern JSClass* JSB_NSEvent_class; 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #elif defined(__CC_PLATFORM_IOS) 88 | 89 | @interface JSB_UITouch : JSB_NSObject 90 | { 91 | } 92 | @end 93 | 94 | #ifdef __cplusplus 95 | extern "C" { 96 | #endif 97 | void JSB_UITouch_createClass(JSContext* cx, JSObject* globalObj, const char * name ); 98 | extern JSObject* JSB_UITouch_object; 99 | extern JSClass* JSB_UITouch_class; 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | 106 | @interface JSB_UIAccelerometer : JSB_NSObject 107 | { 108 | } 109 | @end 110 | 111 | #ifdef __cplusplus 112 | extern "C" { 113 | #endif 114 | void JSB_UIAccelerometer_createClass(JSContext* cx, JSObject* globalObj, const char * name ); 115 | extern JSObject* JSB_UIAccelerometer_object; 116 | extern JSClass* JSB_UIAccelerometer_class; 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif // __CC_PLATFORM_IOS 123 | 124 | #endif // JSB_INCLUDE_NS 125 | 126 | #endif // __JSB_NS_MANUAL_H 127 | -------------------------------------------------------------------------------- /src/manual/jsb_basic_conversions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 __JSB_BASIC_CONVERSIONS_H 26 | #define __JSB_BASIC_CONVERSIONS_H 27 | 28 | #import 29 | #import "jsb_config.h" 30 | 31 | #include "jsfriendapi.h" 32 | 33 | typedef void (^js_block)(id sender); 34 | 35 | /** Creates a JSObject, a ProxyObject and associates them with the real object */ 36 | JSObject* JSB_create_jsobject_from_realobj( JSContext* context, Class klass, id realObj ); 37 | 38 | /** Gets or Creates a JSObject, a ProxyObject and associates them with the real object */ 39 | JSObject * JSB_get_or_create_jsobject_from_realobj( JSContext *cx, id realObj); 40 | 41 | /** Whether or not the jsval is an NSString. If ret is not null, it returns the converted object. 42 | Like JSB_jsval_to_NSString, but if it is not an NSString it does not report error. 43 | */ 44 | JSBool JSB_jsval_is_NSString( JSContext *cx, jsval vp, NSString **ret ); 45 | 46 | /** Whether or not the jsval is an NSObject. If ret is not null, it returns the converted object. 47 | Like JSB_jsval_to_NSObject, but if it is not an NSObject it does not report error. 48 | */ 49 | JSBool JSB_jsval_is_NSObject( JSContext *cx, jsval vp, NSObject **ret ); 50 | 51 | /** converts a jsval to a NSString */ 52 | JSBool JSB_jsval_to_NSString( JSContext *cx , jsval vp, NSString **out ); 53 | 54 | /** converts a jsval to a NSObject. If jsval is null it will return [NSNull null]. */ 55 | JSBool JSB_jsval_to_NSObject( JSContext *cx, jsval vp, NSObject **out ); 56 | 57 | /** converts a jsval to a NSDictionary */ 58 | JSBool JSB_jsval_to_NSDictionary( JSContext *cx , jsval vp, NSDictionary** out ); 59 | 60 | /** converts a jsval to a NSArray */ 61 | JSBool JSB_jsval_to_NSArray( JSContext *cx , jsval vp, NSArray **out ); 62 | 63 | /** converts a jsval to a NSSet */ 64 | JSBool JSB_jsval_to_NSSet( JSContext *cx , jsval vp, NSSet** out ); 65 | 66 | /** converts a jsval into the most approrate NSObject based on the value */ 67 | JSBool JSB_jsval_to_unknown(JSContext *cx, jsval vp, id* ret); 68 | 69 | /** converts a JSString to a NSString */ 70 | JSBool JSB_JSString_to_NSString( JSContext *cx, JSString *jsstr, NSString **ret ); 71 | 72 | /** converts a variadic jsval to a NSArray */ 73 | JSBool JSB_jsvals_variadic_to_NSArray( JSContext *cx, jsval *vp, int argc, NSArray** out ); 74 | 75 | JSBool JSB_jsval_to_CGPoint( JSContext *cx, jsval vp, CGPoint *out ); 76 | JSBool JSB_jsval_to_CGSize( JSContext *cx, jsval vp, CGSize *out ); 77 | JSBool JSB_jsval_to_CGRect( JSContext *cx, jsval vp, CGRect *out ); 78 | /** converts a jsval to a 'handle'. Typically the handle is pointer to a struct */ 79 | JSBool JSB_jsval_to_opaque( JSContext *cx, jsval vp, void **out ); 80 | /** copies the contents of an array buffer view. */ 81 | JSBool JSB_jsval_to_struct( JSContext *cx, jsval vp, void *r, size_t size); 82 | JSBool JSB_jsval_to_int32( JSContext *cx, jsval vp, int32_t *out); 83 | JSBool JSB_jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *ret ); 84 | JSBool JSB_jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *ret ); 85 | JSBool JSB_jsval_to_long( JSContext *cx, jsval vp, long *out); 86 | JSBool JSB_jsval_to_longlong( JSContext *cx, jsval vp, long long *out); 87 | /** converts a jsval to a "handle" needed for Object Oriented C API */ 88 | JSBool JSB_jsval_to_c_class( JSContext *cx, jsval vp, void **r, struct jsb_c_proxy_s **out_proxy_optional); 89 | /** converts a jsval to a block (1 == receives 1 argument (sender) ) */ 90 | JSBool JSB_jsval_to_block_1( JSContext *cx, jsval vp, JSObject *jsthis, js_block *out ); 91 | /** converts a jsval to a block (2 == receives 2 argument (sender + custom) ) */ 92 | JSBool JSB_jsval_to_block_2( JSContext *cx, jsval vp, JSObject *jsthis, jsval arg, js_block *out ); 93 | /** converts a jsval (JS string) into a char */ 94 | JSBool JSB_jsval_to_charptr( JSContext *cx, jsval vp, const char **out); 95 | /** converts a typedarray-like sequence (typedarray or array of numbers) into a data pointer */ 96 | JSBool JSB_jsval_typedarray_to_dataptr( JSContext *cx, jsval vp, GLsizei *count, void **data, JSArrayBufferViewType t); 97 | /** obtains the data pointer and size from an Array Buffer View (think of TypedArrays).*/ 98 | JSBool JSB_get_arraybufferview_dataptr( JSContext *cx, jsval vp, GLsizei *count, GLvoid **data ); 99 | 100 | jsval JSB_unknown_to_jsval( JSContext *cx, id obj); 101 | /** Converts an NSObject into a jsval. It does not creates a new object if the NSObject has already been converted */ 102 | jsval JSB_jsval_from_NSObject( JSContext *cx, id object); 103 | jsval JSB_jsval_from_NSString( JSContext *cx, NSString *str); 104 | jsval JSB_jsval_from_NSNumber( JSContext *cx, NSNumber *number); 105 | jsval JSB_jsval_from_NSDictionary( JSContext *cx, NSDictionary *dict); 106 | jsval JSB_jsval_from_NSArray( JSContext *cx, NSArray *array); 107 | jsval JSB_jsval_from_NSSet( JSContext *cx, NSSet *set); 108 | jsval JSB_jsval_from_int32( JSContext *cx, int32_t l); 109 | jsval JSB_jsval_from_uint32( JSContext *cx, uint32_t number ); 110 | jsval JSB_jsval_from_long( JSContext *cx, long l); 111 | jsval JSB_jsval_from_longlong( JSContext *cx, long long l); 112 | jsval JSB_jsval_from_CGPoint( JSContext *cx, CGPoint p ); 113 | jsval JSB_jsval_from_CGSize( JSContext *cx, CGSize s); 114 | jsval JSB_jsval_from_CGRect( JSContext *cx, CGRect r); 115 | /** Converts an C Structure (handle) into a jsval. It returns jsval that will be sued as a "pointer" to the C Structure */ 116 | jsval JSB_jsval_from_opaque( JSContext *cx, void* opaque); 117 | /** Converts an C class (a structure) into a jsval. It does not creates a new object it the C class has already been converted */ 118 | jsval JSB_jsval_from_c_class( JSContext *cx, void* handle, JSObject* object, JSClass *klass, const char* optional_class_name); 119 | /* Converts a char ptr into a jsval (using JS string) */ 120 | jsval JSB_jsval_from_charptr( JSContext *cx, const char *str); 121 | jsval JSB_jsval_from_unknown( JSContext *cx, id obj); 122 | jsval JSB_jsval_from_struct( JSContext *cx, GLsizei count, void *data, JSArrayBufferViewType t); 123 | 124 | /** Adds GC roots for funcval and jsthis tied to the lifetime of a block */ 125 | @interface JSB_Callback : NSObject 126 | { 127 | } 128 | @property (nonatomic, readonly, assign) JSContext *cx; 129 | @property (nonatomic, readonly, assign) JSObject *jsthis; 130 | @property (nonatomic, readonly, assign) jsval funcval; 131 | 132 | - (id) initWithContext:(JSContext *)cx funcval:(jsval)funcval jsthis:(JSObject*)jsthis; 133 | 134 | @end 135 | 136 | JSB_Callback* JSB_prepare_callback( JSContext *cx, JSObject *jsthis, jsval funcval); 137 | JSBool JSB_execute_callback( JSB_Callback *cb, unsigned argc, jsval *argv, jsval *rval); 138 | 139 | 140 | #ifndef _UINT32 141 | typedef uint32_t uint32; 142 | #define _UINT32 143 | #endif // _UINT32 144 | 145 | #endif // __JSB_BASIC_CONVERSIONS_H 146 | -------------------------------------------------------------------------------- /src/manual/jsb_chipmunk_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | 26 | #ifndef __jsb_chipmunk_manual 27 | #define __jsb_chipmunk_manual 28 | 29 | #import "jsb_config.h" 30 | #ifdef JSB_INCLUDE_CHIPMUNK 31 | 32 | #include "chipmunk.h" 33 | #include "jsapi.h" 34 | 35 | #import "jsb_chipmunk_auto_classes.h" 36 | 37 | // Free Functions 38 | JSBool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); 39 | JSBool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); 40 | 41 | JSBool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp); 42 | JSBool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp); 43 | 44 | // poly related 45 | JSBool JSB_cpAreaForPoly(JSContext *cx, uint32_t argc, jsval *vp); 46 | JSBool JSB_cpMomentForPoly(JSContext *cx, uint32_t argc, jsval *vp); 47 | JSBool JSB_cpCentroidForPoly(JSContext *cx, uint32_t argc, jsval *vp); 48 | JSBool JSB_cpRecenterPoly(JSContext *cx, uint32_t argc, jsval *vp); 49 | 50 | // "Methods" from the OO API 51 | JSBool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); 52 | JSBool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); 53 | 54 | // manually wrapped for rooting/unrooting purposes 55 | JSBool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp); 56 | JSBool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp); 57 | JSBool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp); 58 | JSBool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp); 59 | JSBool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp); 60 | JSBool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp); 61 | JSBool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp); 62 | JSBool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp); 63 | 64 | 65 | JSBool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp); 66 | JSBool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp); 67 | 68 | JSBool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp); 69 | JSBool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp); 70 | JSBool JSB_cpBody_setUserData(JSContext *cx, uint32_t argc, jsval *vp); 71 | 72 | 73 | // convertions 74 | 75 | jsval JSB_jsval_from_cpBB(JSContext *cx, cpBB bb ); 76 | JSBool JSB_jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ); 77 | JSBool JSB_jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numVerts); 78 | 79 | // requires cocos2d 80 | #define JSB_jsval_from_cpVect JSB_jsval_from_CGPoint 81 | #define JSB_jsval_to_cpVect JSB_jsval_to_CGPoint 82 | 83 | 84 | // Object Oriented Chipmunk 85 | void JSB_cpBase_createClass(JSContext* cx, JSObject* globalObj, const char * name ); 86 | extern JSObject* JSB_cpBase_object; 87 | extern JSClass* JSB_cpBase_class; 88 | 89 | // Manual constructor / destructors 90 | JSBool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp); 91 | void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *obj); 92 | 93 | #endif // JSB_INCLUDE_CHIPMUNK 94 | 95 | #endif // __jsb_chipmunk_manual 96 | -------------------------------------------------------------------------------- /src/manual/jsb_chipmunk_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | 26 | #ifndef __JSB_CHIPMUNK_REGISTRATION 27 | #define __JSB_CHIPMUNK_REGISTRATION 28 | 29 | void JSB_register_chipmunk( JSContext *globalC, JSObject *globalO); 30 | 31 | #endif // __JSB_CHIPMUNK_REGISTRATION 32 | -------------------------------------------------------------------------------- /src/manual/jsb_chipmunk_registration.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | #import "jsb_config.h" 26 | #import "jsb_core.h" 27 | 28 | 29 | // chipmunk 30 | #import "jsb_chipmunk_auto_classes.h" 31 | #import "jsb_chipmunk_functions.h" 32 | #import "jsb_chipmunk_manual.h" 33 | 34 | 35 | void JSB_register_chipmunk( JSContext *_cx, JSObject *object) 36 | { 37 | // 38 | // Chipmunk 39 | // 40 | JSObject *chipmunk = JS_NewObject(_cx, NULL, NULL, NULL); 41 | JS::RootedValue chipmunkVal(_cx); 42 | chipmunkVal = OBJECT_TO_JSVAL(chipmunk); 43 | JS_SetProperty(_cx, object, "cp", chipmunkVal); 44 | 45 | JSB_cpBase_createClass(_cx, chipmunk, "Base"); // manual base class registration 46 | #import "jsb_chipmunk_auto_classes_registration.h" 47 | #import "jsb_chipmunk_functions_registration.h" 48 | 49 | // manual 50 | JS_DefineFunction(_cx, chipmunk, "spaceAddCollisionHandler", JSB_cpSpaceAddCollisionHandler, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 51 | JS_DefineFunction(_cx, chipmunk, "spaceRemoveCollisionHandler", JSB_cpSpaceRemoveCollisionHandler, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 52 | JS_DefineFunction(_cx, chipmunk, "arbiterGetBodies", JSB_cpArbiterGetBodies, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 53 | JS_DefineFunction(_cx, chipmunk, "arbiterGetShapes", JSB_cpArbiterGetShapes, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 54 | 55 | JS_DefineFunction(_cx, chipmunk, "areaForPoly", JSB_cpAreaForPoly, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 56 | JS_DefineFunction(_cx, chipmunk, "momentForPoly", JSB_cpMomentForPoly, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 57 | JS_DefineFunction(_cx, chipmunk, "centroidForPoly", JSB_cpCentroidForPoly, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 58 | JS_DefineFunction(_cx, chipmunk, "recenterPoly", JSB_cpRecenterPoly, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/manual/jsb_cocos2d_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | 26 | #import 27 | #import "jsb_config.h" 28 | 29 | #ifdef JSB_INCLUDE_COCOS2D 30 | #import "cocos2d.h" 31 | 32 | JSBool JSB_jsval_to_ccColor3B( JSContext *cx, jsval vp, ccColor3B *ret ); 33 | JSBool JSB_jsval_to_ccColor4B( JSContext *cx, jsval vp, ccColor4B *ret ); 34 | JSBool JSB_jsval_to_ccColor4F( JSContext *cx, jsval vp, ccColor4F *ret ); 35 | jsval JSB_jsval_from_ccColor3B( JSContext *cx, ccColor3B p ); 36 | jsval JSB_jsval_from_ccColor4B( JSContext *cx, ccColor4B p ); 37 | jsval JSB_jsval_from_ccColor4F( JSContext *cx, ccColor4F p ); 38 | 39 | /** returns an array (not NSArray) of CGPoint. caller should call free */ 40 | JSBool JSB_jsval_to_array_of_CGPoint( JSContext *cx, jsval vp, CGPoint**verts, int *numVerts); 41 | 42 | // XXX argh 43 | // Apparently this function has a c++ definition... why??? 44 | 45 | JSBool JSB_CCCardinalSplineBy_actionWithDuration_points_tension__static(JSContext *cx, uint32_t argc, jsval *vp); 46 | JSBool JSB_CCBezierTo_actionWithDuration_bezier__static(JSContext *cx, uint32_t argc, jsval *vp); 47 | 48 | 49 | JSBool JSB_jsval_to_CCFontDefinition( JSContext *cx, jsval vp, CCFontDefinition **ret ); 50 | 51 | #endif // JSB_INCLUDE_COCOS2D 52 | -------------------------------------------------------------------------------- /src/manual/jsb_cocos2d_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | 26 | #ifndef __JSB_COCOS2D_REGISTRATION 27 | #define __JSB_COCOS2D_REGISTRATION 28 | 29 | void JSB_register_cocos2d( JSContext *globalC, JSObject *globalO); 30 | 31 | #endif // __JSB_COCOS2D_REGISTRATION 32 | -------------------------------------------------------------------------------- /src/manual/jsb_cocos2d_registration.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | #import "jsb_config.h" 26 | #import "jsb_core.h" 27 | 28 | #import "jsb_cocos2d_registration.h" 29 | 30 | // cocos2d 31 | #import "jsb_cocos2d_classes.h" 32 | #import "jsb_cocos2d_functions.h" 33 | #ifdef __CC_PLATFORM_IOS 34 | #import "jsb_cocos2d_ios_classes.h" 35 | #import "jsb_cocos2d_ios_functions.h" 36 | #elif defined(__CC_PLATFORM_MAC) 37 | #import "jsb_cocos2d_mac_classes.h" 38 | #import "jsb_cocos2d_mac_functions.h" 39 | #endif 40 | 41 | // CocosDenshion 42 | #import "jsb_CocosDenshion_classes.h" 43 | 44 | // CocosBuilder reader 45 | #import "jsb_CocosBuilderReader_classes.h" 46 | 47 | // forward declarations 48 | void JSB_GLNode_createClass(JSContext *cx, JSObject* globalObj, const char* name ); 49 | void JSB_register_cocos2d_config( JSContext *_cx, JSObject *cocos2d); 50 | 51 | // 52 | 53 | void JSB_register_cocos2d_config( JSContext *_cx, JSObject *cocos2d) 54 | { 55 | JS_DefineFunction(_cx, cocos2d, "log", JSB_core_log, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 56 | 57 | JSB_NSObject_createClass(_cx, cocos2d, "Object"); 58 | #ifdef __CC_PLATFORM_MAC 59 | JSB_NSEvent_createClass(_cx, cocos2d, "Event"); 60 | #elif defined(__CC_PLATFORM_IOS) 61 | JSB_UITouch_createClass(_cx, cocos2d, "Touch"); 62 | JSB_UIAccelerometer_createClass(_cx, cocos2d, "Accelerometer"); 63 | #endif 64 | } 65 | 66 | void JSB_register_cocos2d( JSContext *_cx, JSObject *object) 67 | { 68 | // 69 | // cocos2d 70 | // 71 | JSObject *cocos2d = JS_NewObject(_cx, NULL, NULL, NULL); 72 | JS::RootedValue cocosVal(_cx); 73 | cocosVal = OBJECT_TO_JSVAL(cocos2d); 74 | JS_SetProperty(_cx, object, "cc", cocosVal); 75 | 76 | 77 | // register "config" object 78 | JSB_register_cocos2d_config(_cx, cocos2d); 79 | 80 | 81 | // Register classes: base classes should be registered first 82 | 83 | #import "jsb_cocos2d_classes_registration.h" 84 | // Manual GLNode registration 85 | JSB_GLNode_createClass(_cx, cocos2d, "GLNode"); 86 | 87 | #import "jsb_cocos2d_functions_registration.h" 88 | 89 | #ifdef __CC_PLATFORM_IOS 90 | JSObject *cocos2d_ios = cocos2d; 91 | #import "jsb_cocos2d_ios_classes_registration.h" 92 | #import "jsb_cocos2d_ios_functions_registration.h" 93 | #elif defined(__CC_PLATFORM_MAC) 94 | JSObject *cocos2d_mac = cocos2d; 95 | #import "jsb_cocos2d_mac_classes_registration.h" 96 | #import "jsb_cocos2d_mac_functions_registration.h" 97 | #endif 98 | 99 | 100 | // 101 | // CocosDenshion 102 | // 103 | // Reuse "cc" namespace for CocosDenshion 104 | JSObject *CocosDenshion = cocos2d; 105 | #import "jsb_CocosDenshion_classes_registration.h" 106 | 107 | // 108 | // CocosBuilderReader 109 | // 110 | // Reuse "cc" namespace for CocosBuilderReader 111 | JSObject *CocosBuilderReader = cocos2d; 112 | #import "jsb_CocosBuilderReader_classes_registration.h" 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/manual/jsb_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | 26 | #ifndef __JS_BINDINGS_CONFIG_H 27 | #define __JS_BINDINGS_CONFIG_H 28 | 29 | 30 | /** @def JSB_ASSERT_ON_FAIL 31 | Wheter or not to assert when the arguments or conversions are incorrect. 32 | It is recommened to turn it off in Release mode. 33 | */ 34 | #ifndef JSB_ASSERT_ON_FAIL 35 | #define JSB_ASSERT_ON_FAIL 0 36 | #endif 37 | 38 | 39 | #if JSB_ASSERT_ON_FAIL 40 | #define JSB_PRECONDITION( condition, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) 41 | #define JSB_PRECONDITION2( condition, context, ret_value, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) 42 | #define ASSERT( condition, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) 43 | 44 | #else 45 | #define JSB_PRECONDITION( condition, error_msg) do { \ 46 | if( ! (condition) ) { \ 47 | JSContext* globalContext = [[JSBCore sharedInstance] globalContext]; \ 48 | if( ! JS_IsExceptionPending( globalContext ) ) { \ 49 | printf("jsb: ERROR in %s: %s\n", __FUNCTION__, error_msg); \ 50 | JS_ReportError( globalContext, error_msg ); \ 51 | } else { \ 52 | JS_ReportPendingException(globalContext); \ 53 | } \ 54 | return JS_FALSE; \ 55 | } \ 56 | } while(0) 57 | #define JSB_PRECONDITION2( condition, context, ret_value, error_msg) do { \ 58 | if( ! (condition) ) { \ 59 | printf("jsb: ERROR in %s: %s\n", __FUNCTION__, error_msg); \ 60 | if( ! JS_IsExceptionPending( context ) ) { \ 61 | printf("jsb: ERROR in %s: %s\n", __FUNCTION__, error_msg); \ 62 | } else { \ 63 | JS_ReportPendingException(context); \ 64 | } \ 65 | return ret_value; \ 66 | } \ 67 | } while(0) 68 | #define ASSERT( condition, error_msg) do { \ 69 | if( ! (condition) ) { \ 70 | printf("jsb: ERROR in %s: %s\n", __FUNCTION__, error_msg); \ 71 | return false; \ 72 | } \ 73 | } while(0) 74 | #endif 75 | 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_NS 91 | Whether or not it should include JS bindings for basic NS* / Cocoa / CocoaTouch objects. 92 | It should be enabled in order to support bindings for any objective-c projects. 93 | Not needed for pure C projects. 94 | Enabled by default. 95 | */ 96 | #ifndef JSB_INCLUDE_NS 97 | #define JSB_INCLUDE_NS 1 98 | #endif // JSB_INCLUDE_NS 99 | 100 | 101 | /** @def JSB_INCLUDE_COCOS2D 102 | Whether or not it should include JS bindings for cocos2d. 103 | */ 104 | #ifndef JSB_INCLUDE_COCOS2D 105 | #define JSB_INCLUDE_COCOS2D 1 106 | 107 | #import "cocos2d.h" 108 | #if defined(__CC_PLATFORM_IOS) 109 | #define JSB_INCLUDE_COCOS2D_IOS 1 110 | #elif defined(__CC_PLATFORM_MAC) 111 | #define JSB_INCLUDE_COCOS2D_MAC 1 112 | #endif 113 | 114 | #endif // JSB_INCLUDE_COCOS2D 115 | 116 | 117 | /** @def JSB_INCLUDE_CHIPMUNK 118 | Whether or not it should include JS bindings for Chipmunk 119 | */ 120 | #ifndef JSB_INCLUDE_CHIPMUNK 121 | #define JSB_INCLUDE_CHIPMUNK 1 122 | #endif // JSB_INCLUDE_CHIPMUNK 123 | 124 | 125 | /** @def JSB_INCLUDE_COCOSBUILDERREADER 126 | Whether or not it should include JS bindings for CocosBuilder Reader 127 | */ 128 | #ifndef JSB_INCLUDE_COCOSBUILDERREADER 129 | #define JSB_INCLUDE_COCOSBUILDERREADER 1 130 | #endif // JSB_INCLUDE_COCOSBUILDERREADER 131 | 132 | /** @def JSB_INCLUDE_COCOSDENSHION 133 | Whether or not it should include bindings for CocosDenshion (sound engine) 134 | */ 135 | #ifndef JSB_INCLUDE_COCOSDENSHION 136 | #define JSB_INCLUDE_COCOSDENSHION 1 137 | #endif // JSB_INCLUDE_COCOSDENSHION 138 | 139 | /** @def JSB_INCLUDE_SYSTEM 140 | Whether or not it should include bindings for system components like LocalStorage 141 | */ 142 | #ifndef JSB_INCLUDE_SYSTEM 143 | #define JSB_INCLUDE_SYSTEM 1 144 | #endif // JSB_INCLUDE_SYSTEM 145 | 146 | /** @def JSB_INCLUDE_OPENGL 147 | Whether or not it should include bindings for WebGL / OpenGL ES 2.0 148 | */ 149 | #ifndef JSB_INCLUDE_OPENGL 150 | #define JSB_INCLUDE_OPENGL 1 151 | #endif // JSB_INCLUDE_OPENGL 152 | 153 | /** @def JSB_ENABLE_JSC_AUTOGENERATION 154 | Set this to 1 to enable auto "JS Encoded" (.jsc) files from JS (.js) files. 155 | - .jsc files load 15% faster than .js files. 156 | - Generating the .jsc files increases the "parsing" time in about %60 (it is done only once). 157 | - .jsc files could be used to protect the source code your JavaScript code. 158 | */ 159 | #ifndef JSB_ENABLE_JSC_AUTOGENERATION 160 | #define JSB_ENABLE_JSC_AUTOGENERATION 0 161 | #endif // JSB_ENABLE_JSC_AUTOGENERATION 162 | 163 | /** @def JSB_ENABLE_DEBUGGER 164 | Set this to 1 to enable the debugger 165 | */ 166 | #ifndef JSB_ENABLE_DEBUGGER 167 | #define JSB_ENABLE_DEBUGGER 0 168 | #endif // JSB_ENABLE_DEBUGGER 169 | 170 | /** @def JSB_DEBUGGER_OUTPUT_STDOUT 171 | Set this to 1 to send the debugger output to the stdout *and* to the socket 172 | */ 173 | #ifndef JSB_DEBUGGER_OUTPUT_STDOUT 174 | #define JSB_DEBUGGER_OUTPUT_STDOUT 0 175 | #endif // JSB_DEBUGGER_OUTPUT_STDOUT 176 | 177 | /** @def JSB_DEBUGGER_PORT 178 | TCP port used to connect to the debugger 179 | */ 180 | #ifndef JSB_DEBUGGER_PORT 181 | #define JSB_DEBUGGER_PORT 5086 182 | #endif // JSB_DEBUGGER_PORT 183 | 184 | #ifndef JSB_MAX_STACK_QUOTA 185 | #ifdef DEBUG 186 | #define JSB_MAX_STACK_QUOTA 5000000 187 | #else 188 | #define JSB_MAX_STACK_QUOTA 500000 189 | #endif 190 | #endif // JSB_MAX_STACK_QUOTA 191 | 192 | #if 1 193 | #define JSB_ENSURE_AUTOCOMPARTMENT(cx, obj) \ 194 | JSAutoCompartment ac(cx, obj) 195 | #else 196 | #define JSB_ENSURE_AUTOCOMPARTMENT(cx, obj) 197 | #endif 198 | 199 | #endif // __JS_BINDINGS_CONFIG_H 200 | -------------------------------------------------------------------------------- /src/manual/jsb_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 __JSB_CORE_H 26 | #define __JSB_CORE_H 27 | 28 | #import 29 | #include "jsapi.h" 30 | 31 | #import "cocos2d.h" 32 | #import "chipmunk.h" 33 | #import "SimpleAudioEngine.h" 34 | 35 | // Globals 36 | // one shared key for associations 37 | extern char * JSB_association_proxy_key; 38 | 39 | /** 40 | */ 41 | @interface JSBCore : NSObject 42 | { 43 | JSRuntime *_rt; 44 | JSContext *_cx; 45 | JSObject *_object; 46 | JSObject *_debugObject; 47 | } 48 | 49 | /** return the global context */ 50 | @property (nonatomic, readonly) JSRuntime* runtime; 51 | 52 | /** return the global context */ 53 | @property (nonatomic, readonly) JSContext* globalContext; 54 | 55 | /** return the global container */ 56 | @property (nonatomic, readonly) JSObject* globalObject; 57 | 58 | /** return the debug container */ 59 | @property (nonatomic, readonly) JSObject* debugObject; 60 | 61 | /** returns the shared instance */ 62 | +(JSBCore*) sharedInstance; 63 | 64 | /** 65 | * @param cx 66 | * @param message 67 | * @param report 68 | */ 69 | +(void) reportErrorWithContext:(JSContext*)cx message:(NSString*)message report:(JSErrorReport*)report; 70 | 71 | /** 72 | * Log something using CCLog 73 | * @param cx 74 | * @param argc 75 | * @param vp 76 | */ 77 | +(JSBool) logWithContext:(JSContext*)cx argc:(uint32_t)argc vp:(jsval*)vp; 78 | 79 | /** 80 | * run a script from script :) 81 | */ 82 | +(JSBool) executeScriptWithContext:(JSContext*)cx argc:(uint32_t)argc vp:(jsval*)vp; 83 | 84 | /** 85 | * Register an object as a member of the GC's root set, preventing 86 | * them from being GC'ed 87 | */ 88 | +(JSBool) addRootJSWithContext:(JSContext*)cx argc:(uint32_t)argc vp:(jsval*)vp; 89 | 90 | /** 91 | * removes an object from the GC's root, allowing them to be GC'ed if no 92 | * longer referenced. 93 | */ 94 | +(JSBool) removeRootJSWithContext:(JSContext*)cx argc:(uint32_t)argc vp:(jsval*)vp; 95 | 96 | /** 97 | * Force a cycle of GC 98 | */ 99 | +(JSBool) forceGCWithContext:(JSContext*)cx argc:(uint32_t)argc vp:(jsval*)vp; 100 | 101 | /** creates a new runtime */ 102 | -(void) createRuntime; 103 | 104 | /** restarts the JS runtime. 105 | It will call `shutdown` and then it will call `createRuntime`. 106 | */ 107 | -(void) restartRuntime; 108 | 109 | /** Shutdown the VM. 110 | All created objects are going to be destroyed, including the caches 111 | */ 112 | -(void) shutdown; 113 | 114 | /** Purge the caches that mantains associations between native and JS objects 115 | */ 116 | -(void) purgeCache; 117 | 118 | /** 119 | * will eval the specified string 120 | * @param string The string with the javascript code to be evaluated 121 | * @param outVal The jsval that will hold the return value of the evaluation. 122 | * Can be NULL. 123 | */ 124 | -(BOOL) evalString:(NSString*)string outVal:(jsval*)outVal; 125 | 126 | /** 127 | * will run the specified script using the default container 128 | * @param filename The path of the script to be run 129 | */ 130 | -(JSBool) runScript:(NSString*)filename; 131 | 132 | /** 133 | * will run the specified script 134 | * @param filename The path of the script to be run 135 | * @param global The path of the script to be run 136 | */ 137 | -(JSBool) runScript:(NSString*)filename withContainer:(JSObject *)global; 138 | 139 | -(JSScript*) decodeScript:(NSString*)filename; 140 | 141 | -(void) encodeScript:(JSScript *)script filename:(NSString*)filename; 142 | 143 | -(NSString*) cachedFullpathForJSC:(NSString*)path; 144 | 145 | @end 146 | 147 | #ifdef __cplusplus 148 | extern "C" { 149 | #endif 150 | 151 | enum { 152 | JSB_C_FLAG_CALL_FREE = 0, 153 | JSB_C_FLAG_DO_NOT_CALL_FREE =1, 154 | }; 155 | 156 | // structure used by "Object Oriented Functions". 157 | // handle is a pointer to the native object 158 | // flags: flags for the object 159 | struct jsb_c_proxy_s { 160 | unsigned long flags; // Should it be removed at "destructor" time, or not ? 161 | void *handle; // native object, like cpSpace, cpBody, etc. 162 | JSObject *jsobj; // JS Object. Needed for rooting / unrooting 163 | }; 164 | 165 | // Functions for setting / removing / getting the proxy used by the "C" Object Oriented API. Think of Chipmunk classes 166 | struct jsb_c_proxy_s* JSB_get_c_proxy_for_jsobject( JSObject *jsobj ); 167 | void JSB_del_c_proxy_for_jsobject( JSObject *jsobj ); 168 | void JSB_set_c_proxy_for_jsobject( JSObject *jsobj, void *handle, unsigned long flags); 169 | 170 | // JSObject -> proxy 171 | /** gets a proxy for a given JSObject */ 172 | void* JSB_get_proxy_for_jsobject(JSObject *jsobj); 173 | /** sets a proxy for a given JSObject */ 174 | void JSB_set_proxy_for_jsobject(void* proxy, JSObject *jsobj); 175 | /** dels a proxy for a given JSObject */ 176 | void JSB_del_proxy_for_jsobject(JSObject *jsobj); 177 | 178 | // reverse: proxy -> JSObject 179 | /** gets a JSObject for a given proxy */ 180 | JSObject* JSB_get_jsobject_for_proxy(void *proxy); 181 | /** sets a JSObject for a given proxy */ 182 | void JSB_set_jsobject_for_proxy(JSObject *jsobj, void* proxy); 183 | /** delts a JSObject for a given proxy */ 184 | void JSB_del_jsobject_for_proxy(void* proxy); 185 | 186 | JSBool JSB_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value); 187 | 188 | 189 | // needed for callbacks. It does nothing. 190 | JSBool JSB_do_nothing(JSContext *cx, uint32_t argc, jsval *vp); 191 | 192 | 193 | // logs a format string to the console 194 | JSBool JSB_core_log(JSContext *cx, uint32_t argc, jsval *vp); 195 | 196 | JSObject* JSB_NewGlobalObject(JSContext* cx, bool empty); 197 | 198 | extern const char* JSB_version; 199 | 200 | #ifdef __cplusplus 201 | } 202 | #endif 203 | 204 | #endif // __JSB_CORE_H 205 | -------------------------------------------------------------------------------- /src/manual/jsb_dbg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 __JSB_DBG__ 26 | #define __JSB_DBG__ 27 | 28 | #include 29 | #include 30 | #import "jsb_core.h" 31 | 32 | @interface JSBCore (Debugger) 33 | - (void)debugProcessInput:(NSString *)str; 34 | - (void)enableDebugger; 35 | @end 36 | 37 | extern std::map __scripts; 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | void debugProcessInput(std::string data); 44 | 45 | JSBool JSBDebug_StartDebugger(JSContext* cx, unsigned argc, jsval* vp); 46 | JSBool JSBDebug_BufferRead(JSContext* cx, unsigned argc, jsval* vp); 47 | JSBool JSBDebug_BufferWrite(JSContext* cx, unsigned argc, jsval* vp); 48 | JSBool JSBDebug_LockExecution(JSContext* cx, unsigned argc, jsval* vp); 49 | JSBool JSBDebug_UnlockExecution(JSContext* cx, unsigned argc, jsval* vp); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/manual/jsb_dbg.mm: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "jsb_dbg.h" 12 | #include "jsb_config.h" 13 | #include "jsdbgapi.h" 14 | 15 | #if DEBUG 16 | #define TRACE_DEBUGGER_SERVER(...) CCLOG(__VA_ARGS__) 17 | #else 18 | #define TRACE_DEBUGGER_SERVER(...) 19 | #endif // #if DEBUG 20 | 21 | using namespace std; 22 | 23 | pthread_t debugThread; 24 | string inData; 25 | string outData; 26 | vector queue; 27 | pthread_mutex_t g_qMutex; 28 | pthread_mutex_t g_rwMutex; 29 | bool vmLock = false; 30 | jsval frame = JSVAL_NULL, script = JSVAL_NULL; 31 | int clientSocket; 32 | 33 | void debugProcessInput(string data) { 34 | NSString* str = [NSString stringWithUTF8String:data.c_str()]; 35 | if (vmLock) { 36 | pthread_mutex_lock(&g_qMutex); 37 | queue.push_back(string(data)); 38 | pthread_mutex_unlock(&g_qMutex); 39 | } else { 40 | [[JSBCore sharedInstance] performSelector:@selector(debugProcessInput:) onThread:[NSThread mainThread] withObject:str waitUntilDone:YES]; 41 | } 42 | } 43 | 44 | static void _clientSocketWriteAndClearString(string& s) { 45 | #if JSB_DEBUGGER_OUTPUT_STDOUT 46 | write(STDOUT_FILENO, s.c_str(), s.length()); 47 | #endif 48 | write(clientSocket, s.c_str(), s.length()); 49 | s.clear(); 50 | } 51 | 52 | void clearBuffers() { 53 | pthread_mutex_lock(&g_rwMutex); 54 | { 55 | // only process input if there's something and we're not locked 56 | if (inData.length() > 0) { 57 | debugProcessInput(inData); 58 | inData.clear(); 59 | } 60 | if (outData.length() > 0) { 61 | _clientSocketWriteAndClearString(outData); 62 | } 63 | } 64 | pthread_mutex_unlock(&g_rwMutex); 65 | } 66 | 67 | void* serverEntryPoint(void*) 68 | { 69 | #if TARGET_OS_IPHONE || TARGET_OS_MAC 70 | // this just in case 71 | @autoreleasepool 72 | { 73 | #endif 74 | // init the mutex 75 | assert(pthread_mutex_init(&g_rwMutex, NULL) == 0); 76 | assert(pthread_mutex_init(&g_qMutex, NULL) == 0); 77 | // start a server, accept the connection and keep reading data from it 78 | struct addrinfo hints, *result, *rp; 79 | int s; 80 | memset(&hints, 0, sizeof(struct addrinfo)); 81 | hints.ai_family = AF_INET; 82 | hints.ai_socktype = SOCK_STREAM; // TCP 83 | 84 | int err; 85 | stringstream portstr; 86 | portstr << JSB_DEBUGGER_PORT; 87 | const char* tmp = portstr.str().c_str(); 88 | if ((err = getaddrinfo(NULL, tmp, &hints, &result)) != 0) { 89 | printf("error: %s\n", gai_strerror(err)); 90 | } 91 | 92 | for (rp = result; rp != NULL; rp = rp->ai_next) { 93 | if ((s = socket(rp->ai_family, rp->ai_socktype, 0)) < 0) { 94 | continue; 95 | } 96 | int optval = 1; 97 | if ((setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(optval))) < 0) { 98 | close(s); 99 | TRACE_DEBUGGER_SERVER(@"debug server : error setting socket option SO_REUSEADDR"); 100 | return NULL; 101 | } 102 | 103 | if ((setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval))) < 0) { 104 | close(s); 105 | TRACE_DEBUGGER_SERVER(@"debug server : error setting socket option SO_NOSIGPIPE"); 106 | return NULL; 107 | } 108 | 109 | if ((::bind(s, rp->ai_addr, rp->ai_addrlen)) == 0) { 110 | break; 111 | } 112 | close(s); 113 | s = -1; 114 | } 115 | if (s < 0 || rp == NULL) { 116 | TRACE_DEBUGGER_SERVER(@"debug server : error creating/binding socket"); 117 | return NULL; 118 | } 119 | 120 | freeaddrinfo(result); 121 | 122 | listen(s, 1); 123 | while (true) { 124 | clientSocket = accept(s, NULL, NULL); 125 | if (clientSocket < 0) 126 | { 127 | TRACE_DEBUGGER_SERVER(@"debug server : error on accept"); 128 | return NULL; 129 | } else { 130 | // read/write data 131 | TRACE_DEBUGGER_SERVER(@"debug server : client connected"); 132 | char buf[256]; 133 | int readBytes; 134 | while ((readBytes = read(clientSocket, buf, 256)) > 0) { 135 | buf[readBytes] = '\0'; 136 | TRACE_DEBUGGER_SERVER(@"debug server : received command >%s", buf); 137 | // no other thread is using this 138 | inData.append(buf); 139 | // process any input, send any output 140 | clearBuffers(); 141 | } // while(read) 142 | close(clientSocket); 143 | } 144 | } // while(true) 145 | // we're done, destroy the mutex 146 | pthread_mutex_destroy(&g_rwMutex); 147 | pthread_mutex_destroy(&g_qMutex); 148 | #if TARGET_OS_IPHONE || TARGET_OS_MAC 149 | } 150 | #endif 151 | return NULL; 152 | } 153 | 154 | @implementation JSBCore (Debugger) 155 | 156 | /** 157 | * if we're on a breakpoint, this will pass the right frame & script 158 | */ 159 | - (void)debugProcessInput:(NSString *)str { 160 | JSString* jsstr = JS_NewStringCopyZ(_cx, [str UTF8String]); 161 | jsval argv[3] = { 162 | STRING_TO_JSVAL(jsstr), 163 | frame, 164 | script 165 | }; 166 | { 167 | JSAutoCompartment ac(_cx, _debugObject); 168 | JS_WrapValue(_cx, &argv[0]); 169 | JS_WrapValue(_cx, &argv[1]); 170 | JS_WrapValue(_cx, &argv[2]); 171 | jsval outval; 172 | JSBool ok = JS_CallFunctionName(_cx, _debugObject, "processInput", 3, argv, &outval); 173 | if (!ok) { 174 | JS_ReportPendingException(_cx); 175 | } 176 | } 177 | } 178 | 179 | - (void)enableDebugger 180 | { 181 | if (_debugObject == NULL) { 182 | _debugObject = JSB_NewGlobalObject(_cx, true); 183 | { 184 | JSAutoCompartment ac(_cx, _debugObject); 185 | // these are used in the debug program 186 | JS_DefineFunction(_cx, _debugObject, "_bufferWrite", JSBDebug_BufferWrite, 1, JSPROP_READONLY | JSPROP_PERMANENT); 187 | JS_DefineFunction(_cx, _debugObject, "_bufferRead", JSBDebug_BufferRead, 0, JSPROP_READONLY | JSPROP_PERMANENT); 188 | JS_DefineFunction(_cx, _debugObject, "_lockVM", JSBDebug_LockExecution, 2, JSPROP_READONLY | JSPROP_PERMANENT); 189 | JS_DefineFunction(_cx, _debugObject, "_unlockVM", JSBDebug_UnlockExecution, 0, JSPROP_READONLY | JSPROP_PERMANENT); 190 | JS_DefineFunction(_cx, _debugObject, "log", JSB_core_log, 0, JSPROP_READONLY | JSPROP_PERMANENT); 191 | [self runScript:@"jsb_debugger.js" withContainer:_debugObject]; 192 | 193 | jsval outval; 194 | // prepare the debugger 195 | jsval oldGlobal = OBJECT_TO_JSVAL(_object); 196 | JS_WrapValue(_cx, &oldGlobal); 197 | JSBool ok = JS_CallFunctionName(_cx, _debugObject, "_prepareDebugger", 1, &oldGlobal, &outval); 198 | if (!ok) { 199 | JS_ReportPendingException(_cx); 200 | } 201 | } 202 | { 203 | // define the start debugger function 204 | JSAutoCompartment ae(_cx, _object); 205 | JS_DefineFunction(_cx, _object, "startDebugger", JSBDebug_StartDebugger, 3, JSPROP_READONLY | JSPROP_PERMANENT); 206 | } 207 | // start bg thread 208 | pthread_create(&debugThread, NULL, serverEntryPoint, NULL); 209 | } 210 | } 211 | 212 | @end 213 | 214 | JSBool JSBDebug_StartDebugger(JSContext* cx, unsigned argc, jsval* vp) 215 | { 216 | JSObject *debugGlobal = [[JSBCore sharedInstance] debugObject]; 217 | if (argc >= 2) { 218 | jsval* argv = JS_ARGV(cx, vp); 219 | jsval outval; 220 | // JS_WrapObject(cx, debugGlobal->address()); 221 | JSAutoCompartment ac(cx, debugGlobal); 222 | JSBool ok = JS_CallFunctionName(cx, debugGlobal, "_startDebugger", argc, argv, &outval); 223 | if (!ok) { 224 | JS_ReportPendingException(cx); 225 | } 226 | return ok; 227 | } else { 228 | JS_ReportError(cx, "Invalid call to startDebugger()"); 229 | } 230 | return JS_FALSE; 231 | } 232 | 233 | JSBool JSBDebug_BufferRead(JSContext* cx, unsigned argc, jsval* vp) 234 | { 235 | if (argc == 0) { 236 | JSString* str; 237 | // this is safe because we're already inside a lock (from clearBuffers) 238 | if (vmLock) { 239 | pthread_mutex_lock(&g_rwMutex); 240 | } 241 | str = JS_NewStringCopyZ(cx, inData.c_str()); 242 | inData.clear(); 243 | if (vmLock) { 244 | pthread_mutex_unlock(&g_rwMutex); 245 | } 246 | JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); 247 | } else { 248 | JS_SET_RVAL(cx, vp, JSVAL_NULL); 249 | } 250 | return JS_TRUE; 251 | } 252 | 253 | JSBool JSBDebug_BufferWrite(JSContext* cx, unsigned argc, jsval* vp) 254 | { 255 | if (argc == 1) { 256 | jsval* argv = JS_ARGV(cx, vp); 257 | const char* str; 258 | 259 | JSString* jsstr = JS_ValueToString(cx, argv[0]); 260 | str = JS_EncodeString(cx, jsstr); 261 | 262 | // this is safe because we're already inside a lock (from clearBuffers) 263 | outData.append(str); 264 | _clientSocketWriteAndClearString(outData); 265 | 266 | JS_free(cx, (void*)str); 267 | } 268 | return JS_TRUE; 269 | } 270 | 271 | // this should lock the execution of the running thread, waiting for a signal 272 | JSBool JSBDebug_LockExecution(JSContext* cx, unsigned argc, jsval* vp) 273 | { 274 | assert([NSThread currentThread] == [NSThread mainThread]); 275 | if (argc == 2) { 276 | jsval* argv = JS_ARGV(cx, vp); 277 | frame = argv[0]; 278 | script = argv[1]; 279 | vmLock = true; 280 | while (vmLock) { 281 | // try to read the input, if there's anything 282 | pthread_mutex_lock(&g_qMutex); 283 | while (queue.size() > 0) { 284 | vector::iterator first = queue.begin(); 285 | string str = *first; 286 | NSString *nsstr = [NSString stringWithUTF8String:str.c_str()]; 287 | [[JSBCore sharedInstance] performSelector:@selector(debugProcessInput:) withObject:nsstr]; 288 | queue.erase(first); 289 | } 290 | pthread_mutex_unlock(&g_qMutex); 291 | sched_yield(); 292 | } 293 | frame = JSVAL_NULL; 294 | script = JSVAL_NULL; 295 | return JS_TRUE; 296 | } 297 | JS_ReportError(cx, "invalid call to _lockVM"); 298 | return JS_FALSE; 299 | } 300 | 301 | JSBool JSBDebug_UnlockExecution(JSContext* cx, unsigned argc, jsval* vp) 302 | { 303 | vmLock = false; 304 | return JS_TRUE; 305 | } 306 | -------------------------------------------------------------------------------- /src/manual/jsb_opengl_manual.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | 26 | #ifndef __jsb_opengl_manual 27 | #define __jsb_opengl_manual 28 | 29 | #include "jsb_config.h" 30 | #if JSB_INCLUDE_OPENGL 31 | 32 | #include 33 | #include "jsapi.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 | #define glReleaseShaderCompiler() 42 | 43 | #endif // __MAC_OS_X_VERSION_MAX_ALLOWED 44 | 45 | // forward declaration of new functions 46 | JSBool JSB_glGetSupportedExtensions(JSContext *cx, uint32_t argc, jsval *vp); 47 | 48 | 49 | #endif // JSB_INCLUDE_OPENGL 50 | 51 | #endif // __jsb_opengl_manual 52 | -------------------------------------------------------------------------------- /src/manual/jsb_opengl_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | 26 | #ifndef __JSB_OPENGL_REGISTRATION 27 | #define __JSB_OPENGL_REGISTRATION 28 | 29 | void JSB_register_opengl( JSContext *globalC, JSObject *globalO); 30 | 31 | #endif // __JSB_OPENGL_REGISTRATION 32 | -------------------------------------------------------------------------------- /src/manual/jsb_opengl_registration.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | #include "jsb_config.h" 26 | #include "jsb_core.h" 27 | #include "jsb_opengl_manual.h" 28 | 29 | 30 | // system 31 | #import "jsb_opengl_functions.h" 32 | 33 | void JSB_register_opengl( JSContext *_cx, JSObject *object) 34 | { 35 | // 36 | // gl 37 | // 38 | JSObject *opengl = JS_NewObject(_cx, NULL, NULL, NULL); 39 | JS::RootedValue openglVal(_cx); 40 | openglVal = OBJECT_TO_JSVAL(opengl); 41 | JS_SetProperty(_cx, object, "gl", openglVal); 42 | 43 | 44 | // New WebGL functions, not present on OpenGL ES 2.0 45 | JS_DefineFunction(_cx, opengl, "getSupportedExtensions", JSB_glGetSupportedExtensions, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); 46 | 47 | 48 | 49 | #import "jsb_opengl_functions_registration.h" 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/manual/jsb_system_registration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | 26 | #ifndef __JSB_SYSTEM_REGISTRATION 27 | #define __JSB_SYSTEM_REGISTRATION 28 | 29 | void JSB_register_system( JSContext *globalC, JSObject *globalO); 30 | 31 | #endif // __JSB_CHIPMUNK_REGISTRATION 32 | -------------------------------------------------------------------------------- /src/manual/jsb_system_registration.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * JS Bindings: https://github.com/zynga/jsbindings 3 | * 4 | * Copyright (c) 2012 Zynga 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 | #import "jsb_config.h" 26 | #import "jsb_core.h" 27 | #import "LocalStorage.h" 28 | 29 | 30 | // system 31 | #import "jsb_system_functions.h" 32 | 33 | 34 | void JSB_register_system( JSContext *_cx, JSObject *object) 35 | { 36 | // 37 | // sys 38 | // 39 | JSObject *sys = JS_NewObject(_cx, NULL, NULL, NULL); 40 | JS::RootedValue systemVal(_cx); 41 | systemVal = OBJECT_TO_JSVAL(sys); 42 | JS_SetProperty(_cx, object, "sys", systemVal); 43 | 44 | 45 | // sys.localStorage 46 | JSObject *ls = JS_NewObject(_cx, NULL, NULL, NULL); 47 | JS::RootedValue lsVal(_cx); 48 | lsVal = OBJECT_TO_JSVAL(ls); 49 | JS_SetProperty(_cx, sys, "localStorage", lsVal); 50 | 51 | // sys.localStorage functions 52 | JSObject *system = ls; 53 | #import "jsb_system_functions_registration.h" 54 | 55 | 56 | // Init DB with full path 57 | NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 58 | NSString *fullpath = [path stringByAppendingPathComponent:@"jsb.sqlite"]; 59 | localStorageInit([fullpath UTF8String]); 60 | } 61 | 62 | --------------------------------------------------------------------------------