Commit Graph

124 Commits

Author SHA1 Message Date
James Chen 31e91e554e issue #1661: Added CrystalCraze for win32 and fix some compilation errors. 2013-01-17 17:07:18 +08:00
Rolando Abarca 7ab43b9dfc adds missing runLoop for cc2dx (debug) 2013-01-16 14:02:05 -08:00
Rolando Abarca 49432ef742 removes old header file reference 2013-01-16 13:42:41 -08:00
Rolando Abarca e94d8d1693 Merge branch 'gles20' of git://github.com/cocos2d/cocos2d-x into gles20
Conflicts:
	scripting/javascript/bindings/ScriptingCore.h
	scripting/javascript/bindings/js_bindings_config.h
2013-01-15 16:52:47 -08:00
Rolando Abarca 320068930e more debug stuff 2013-01-11 14:29:40 -08:00
Rolando Abarca 5df4b4d997 adding debug support for js 2013-01-11 14:01:36 -08:00
James Chen d15561e826 issue #1653: Checking the return value of jsapi. Return JSVAL_VOID if jsapi has no return value. 2013-01-11 18:57:33 +08:00
James Chen a8361bf703 issue #1653: Checking return value for 'native --> jsval'. 2013-01-11 13:54:57 +08:00
James Chen b662d5c569 fixed #1620: Added license. Removed LocalStorage.h from cocos-ext.h. 2013-01-07 18:06:53 +08:00
James Chen 1d59a36ee9 fixed #1620: Invoking localStorageFree in the destructor of ScriptingCore. Added header file to cocos-ext.h 2013-01-07 17:34:22 +08:00
James Chen 8a21f4fa3c issue #1640: Added some files to iOS Project. 2013-01-05 17:41:19 +08:00
James Chen 421cf31b34 issue #1640: Updated jsbinding for CCPhysicsSprite . 2013-01-05 15:09:19 +08:00
James Chen 9bd302e35b fixed #1627: VS version check in project file. 2012-12-29 13:54:46 +08:00
James Chen 7d9f06b48c fixed #1625: Updated TestCpp. 'ccg' --> 'CCSizeMake' . And exchanged the parameter order for 3D action tests. 2012-12-27 10:55:25 +08:00
James Chen 9a0a5e6b31 issue #1603: fixed some warnings. 2012-12-20 17:18:49 +08:00
James Chen e8c0844dd5 fixed #1617: Some improvements for JS Bindings.
1) Changed cc.REPEAT_FOREVER = - 1 to cc.REPEAT_FOREVER = 0xffffffff
[Reason]: If cc.REPEAT_FOREVER = -1, it will be a very big double value after converting it to double by JS_ValueToNumber on android.
Then cast it to unsigned int, the value will be 0. The schedule will not be able to work.
I don't know why this occurs only on android.
[Solution]: Instead of passing -1 to it, I assign it with max value of unsigned int in c++.

2) Added two helper function, cc.ArrayGetIndexOfObject and cc.ArrayContainsObject.

3) Added JSScheduleWrapper::removeTargetForNativeNode to avoid memory leaks.

4) Improvments for JSTouchDelegate. Added four functions as follows:
// Set the touch delegate to map by using the key (pJSObj).
static void setDelegateForJSObject(JSObject* pJSObj, JSTouchDelegate* pDelegate);

// Get the touch delegate by the key (pJSObj).
static JSTouchDelegate* getDelegateForJSObject(JSObject* pJSObj);

// Remove the delegate by the key (pJSObj).
static void removeDelegateForJSObject(JSObject* pJSObj);

void unregisterTouchDelegate();
And exported cc.unregisterTouchDelegate(); to js.
Fix a memory leak for JSTouchDelegate by making it as an autorelease object.

5) Don't add js callback function to the reserved slot of object.
[Reason]: The target object may execute more than one schedule.
Therefore, previous js callback function will be replaced
by the current one. For example:

this.scheduleOnce(function() { temporary function 1 }, 0.5);
this.scheduleOnce(function() { temporary function 2 }, 0.5);

In this case, the temporary function 1 will be removed from reserved slot 0.
And temporary function 2 will be set to reserved slot 0 of this object.
If gc is triggered before the JSScheduleWrapper::scheduleFunc is invoked,
crash will happen. You could simply reproduce it by adding jsc.garbageCollect(); after scheduleOnce.
[Solution] Because one schedule corresponds to one JSScheduleWrapper, we root
the js callback function in JSScheduleWrapper::setJSCallbackFunc and unroot it
at the destructor of JSScheduleWrapper.
2012-12-18 11:56:44 +08:00
dualface 268aa45d2c rename CCNode:scheduleUpdateScriptHandlerWithPriority() to CCNode::scheduleUpdateWhitPriorityLua()
remove unused functions
2012-12-10 16:09:23 +08:00
dualface c8753f72ef [scripting] add CCNode::scheduleUpdateScriptHandlerWithPriority() 2012-12-10 13:48:27 +08:00
James Chen 34eb3a88c2 Commented JS_SetGCZeal. 2012-12-04 17:23:08 +08:00
minggo 4e7fca3185 merge dualface's pull request for fixing CCLayer script support and fix error for js-binding 2012-12-04 10:52:49 +08:00
James Chen 7c074d4ced issue #1550: fixed a memory leak in jsbinding. 2012-12-03 22:17:53 +08:00
James Chen e3615e2fb1 fixed #1586: Invoking removeAllRoots in ScriptingCore destructor to avoid crash when app exits. 2012-12-01 11:41:50 +08:00
James Chen 36bc0ab0bb Invoking JS_SetGCZeal only when the macros DEBUG and JS_GC_ZEAL is defined. 2012-12-01 11:41:50 +08:00
James Chen 07661a1e21 issue #1581: Added jsb_set_reserved_slot and jsb_get_reserved_slot, 2012-11-30 22:00:30 +08:00
James Chen 15d02e4db8 Merge branch 'iss1581-fix-jsbinding-bugs' of https://github.com/dumganhar/cocos2d-x into iss1583-js-tests
Conflicts:
	scripting/javascript/bindings/cocos2d_specifics.cpp
2012-11-30 21:43:44 +08:00
James Chen 96e2707f39 issue #1583: Added jsvals_variadic_to_ccarray function. 2012-11-30 21:12:14 +08:00
James Chen a814066601 issue #1581: JSBinding bug fixes.
Some fixes of JSBinding codes:
[1] Check whether the proxy was already added in JS_NEW_PROXY
[2] In struct schedFunc_proxy_t, JSScheduleWrapper* --> CCArray*
Reason: One js function may correspond to many targets. To debug this, you could refer to JSScheduleWrapper::dump function. It will prove that i'm right. :)
[3] In ScriptingCore::cleanupSchedulesAndActions function, we must invoke unschedule for all targets and remove the proxy both in _schedFunc_target_ht and _schedTarget_native_ht, otherwise the hash tables will grow bigger and bigger, so I added a new function JSScheduleWrapper::removeAllTargetsForNatiaveNode to make this things easier.
[4] To easily find out the bugs of binding codes, I add JS_SetGCZeal in ScriptingCore::createGlobalContext, it only works in DEBUG mode.
[5] In js_cocos2dx_CCNode_getChildren, we should add the generated array to root to avoid gc happen when invoking JS_SetElement.
[6] The JSCallFuncWrapper isn't needed since an action will be run by a cc.Node and it will be released at the CCNode::cleanup.
[7] Some improvements of JSScheduleWrapper class.
[8] Added a new function JSScheduleWrapper::setTarget, it's for js_CCNode_unschedule to find out which target need to be unscheduled.
[9] Commented JS_SetReservedSlot in js_CCNode_scheduleOnce and js_CCNode_schedule.
Reason:
For js_CCNode_scheduleOnce: Don't add the callback function to the reserved slot of this js object.Since the class of js object may be inherited from cocos class(e.g. cc.Sprite). The subclass will not contain reserved slots. It will crash if invoking this.
For js_CCNode_schedule: Don't add js callback function to the reserved slot of scheduler js object. Since the scheduler is an object always rooted.
So the callback function might not be released when gc comes.I looked inside the implementation of cc.Node.schedule, and it doesn't use JS_SetReservedSlot there.
2012-11-28 22:04:55 +08:00
James Chen 7c1e860d78 issue #1573: Added CocosDragonJS. Made it compiled ok on iOS,android and win32. 2012-11-23 15:09:03 +08:00
James Chen 692d16f296 Minor fix in ScriptingCore::log. 2012-11-22 17:34:58 +08:00
James Chen 89a51433b8 issue #1564: Make TestJavascript works on windows. 2012-11-22 10:24:26 +08:00
Rolando Abarca d9baa8a24d fixes merge conflict 2012-11-19 11:23:08 -08:00
Rolando Abarca ac539667f4 Merge remote-tracking branch 'origin/gles20' into gles20
Conflicts:
	scripting/javascript/bindings/ScriptingCore.cpp
	scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp
2012-11-16 09:44:34 -08:00
James Chen 34f359384c issue #1530: Minor fixes in ScriptingCore.cpp, js_bindings_chipmunk_auto_classes.cpp and js_bindings_chipmunk_funcitons.cpp. 2012-11-16 15:58:20 +08:00
Rohan Kuruvilla 6d59009953 Adding executeAccelerometerEvent for to CCScriptSupport and ScriptingCore 2012-11-16 15:56:29 +08:00
Rohan Kuruvilla 66f85468e5 Adding JS conversion of CCDictionary objects, also modified CCArray conversion 2012-11-16 15:56:27 +08:00
Rohan Kuruvilla 672bed3ed0 Updating bindings for ONE_BY_ONE touch handling 2012-11-16 15:56:27 +08:00
Rolando Abarca 6e9d2e808c improved debugger 2012-11-15 11:14:57 -08:00
Rolando Abarca c9df076378 new JSStringWrapper 2012-11-15 11:14:37 -08:00
Rolando Abarca b894524ed0 removing some warnings 2012-11-15 11:13:21 -08:00
James Chen 449c719d96 issue #1549: Added "ccdictionary_to_jsval" function, now TMXOrthoObjectsTest and TMXIsoObjectsTest don't crash. 2012-11-06 16:11:45 +08:00
James Chen 21e4f80fbd Added "executeAccelerometerEvent" for CCScriptEngineProtocol class. Exported Accelerometer event to JS. 2012-11-06 14:18:13 +08:00
Rohan Kuruvilla b3c6f1a2e1 Adding bindings for CCBReader and other improvements.
1. Added additional CCBReader bindings, including callback support for animationCompleted
2. Improved design for JS CallbackWrappers
3. Added bindings for pDistance
4. Updating cocos2dx.ini
2012-11-01 15:34:23 +08:00
James Chen bdbb70bea5 Merge branch 'gles20' of https://github.com/funkaster/cocos2d-x into js-surith-gnu 2012-10-31 10:04:35 +08:00
James Chen 1ede7b6434 Modifying action/schedules cleanup, ignoring libjs_static.a of debugging version. 2012-10-29 15:10:13 +08:00
Rohan Kuruvilla c24acd4733 Changing ScriptingCore flow of execution of targetted Touch events 2012-10-29 15:06:34 +08:00
Rohan Kuruvilla 7ede1373f7 Adding function to cleanup actions and schedule to ScriptingCore 2012-10-29 15:06:10 +08:00
Rolando Abarca 463ae31180 upgrades to new spidermonkey API
FF beta - this fixes the auto-compartment issue
2012-10-24 11:14:15 -07:00
Rolando Abarca 003f6e4cf3 fixes ScriptingCore for FF 16 API 2012-10-19 09:54:21 -07:00
James Chen 871541ac6b Updated one comment. 2012-10-19 15:03:10 +08:00
James Chen e5096ce091 Made TestJavascript and MoonWarriors work ok on android after merging Rolando's commit. 2012-10-19 15:01:05 +08:00
James Chen 1a373f70ff issue #1517: Upgrading js engine to FF 16.0.1 for IOS. 2012-10-19 13:41:03 +08:00
James Chen de3376b43f issue #1517:[Win32]Upgrading SpiderMonkey js engine to FF 16.0.1 2012-10-19 11:15:23 +08:00
Rolando Abarca b0f02a0773 updates on the js front 2012-10-18 17:44:41 -07:00
Rohan Kuruvilla eafd6ebf08 Fixing restart of context to not leak memory 2012-10-11 18:48:37 -07:00
Rohan Kuruvilla 0c1c5a432d Adding support to pass array of CCPoints from JS 2012-10-11 18:44:46 -07:00
James Chen 9f93b609e8 issue #1469: Added cc.config for js-bindings. 2012-10-10 15:24:20 +08:00
Rohan Kuruvilla 12292afee6 Adding CCSchedule bindings. Also adding CCOrbitCamera bindings and modifying cocos2dx.ini 2012-10-09 15:03:14 -07:00
James Chen 426915dd4a fixed some compilation error for win32 platform. 2012-09-24 11:05:15 +08:00
minggo 29fad4d570 Merge branch 'gles20-android-refactoring' of https://github.com/nicolasgramlich/cocos2d-x into merge_nicolas 2012-09-21 11:05:31 +08:00
Rohan Kuruvilla 9e1e64509b Copying changes previously made into cxx-generator/targets/spidermonkey/common
1. Fixed memory leak while removing proxy objects
2. Fixed JS Context restart
3. Added JS conversion for CCArray
4. Updated generated bindings with some more classes
2012-09-20 18:02:17 -07:00
Rohan Kuruvilla dde8d50d15 Adding member function executeFunctionWithOwner to ScriptingCore 2012-09-20 14:45:35 -07:00
Nicolas Gramlich c2a62875cf Added ANDROID_SCRIPTINGCORE_LOAD_SCRIPTS_FROM_EXTERNAL_ASSET_DIRECTORY flag, that allows to load from external assets directory instead of from internal apk assets directory. 2012-09-13 11:13:02 -07:00
James Chen 7d8b261ced fixed #1477: Abstracts Lua and JS binding protocol, some bugs fixes in lua-binding, adding custom menu on win32 and mac for switching resolutions. 2012-09-11 14:02:33 +08:00
James Chen 708be4e474 Remove 'readFileInMemory' to make it compile ok on win32, initialized the member variables for ScriptingCore class. 2012-08-29 14:49:03 -07:00
folecr 3c11684bf7 Remove commented code 2012-08-28 17:56:01 -07:00
folecr 6c604f02d3 Fix typo and add logs 2012-08-28 17:44:01 -07:00
James Chen 71b147ce2f Use CCFileUtils and CCString to load file contents 2012-08-28 17:43:59 -07:00
James Chen 60dae250f2 Use CCLOG to implement js_log 2012-08-28 17:43:59 -07:00
Rohan Kuruvilla 6c8d2ea75b Fixing GC crash issue. Forcing the GC from Javascript at any time, doesn't crash the app
Fixing GC crash issue. Bug in bind_menu_item. There is no more problem with GC, including force_GC

Updating generated bindings to remove std::string scoping bug
2012-08-28 17:29:25 -07:00
Rohan Kuruvilla 8d7516a0ef Test project for cocos2d-x js. 2012-08-27 10:07:31 -07:00
Rohan Kuruvilla ccd5e0a066 Adding cxx-generator/target/common/* files and generated bindings for cocos2d-x. 2012-08-27 10:02:19 -07:00
folecr 51708123a1 remove scripting/javascript/bindings 2012-08-27 10:01:21 -07:00
Donald Alan Morrison 2b4bab18af Fixed VS2010 Warning C4800: 'JSBool' : forcing value to bool 'true' or
'false' (performance warning).
2012-08-24 09:00:57 -07:00
James Chen 77f1fba566 issue #1399: Adjust folder structure, made it built successfully on win32. 2012-07-20 14:05:52 +08:00