diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index 5bd3c19473..870afa9ee5 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -1258,8 +1258,69 @@ 507B43ED1C3201360067B53E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52B71783AE6D0073F6A7 /* UIKit.framework */; }; 507B43EE1C3201360067B53E /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A52C11783B01F0073F6A7 /* AVFoundation.framework */; }; 507B43F61C3201780067B53E /* libcocos2d tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 507B42111C31BEA70067B53E /* libcocos2d tvOS.a */; }; + 507B44271C336EFA0067B53E /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; + 507B44281C336EFA0067B53E /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA28918CD91510087CE3A /* AppKit.framework */; }; + 507B44291C336EFA0067B53E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 185664921B424694009EF2AE /* Cocoa.framework */; }; + 507B442A1C336EFA0067B53E /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; + 507B442B1C336EFA0067B53E /* libjscocos2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1856630E1B41511B009EF2AE /* libjscocos2d Mac.a */; }; + 507B442C1C336EFA0067B53E /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 826294421AAF071500CB7CF7 /* Security.framework */; }; + 507B442D1C336EFA0067B53E /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = ED545A6C1B68A18300C3958E /* libiconv.dylib */; }; + 507B442E1C336EFA0067B53E /* libcocos2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2d Mac.a */; }; + 507B442F1C336EFA0067B53E /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA36018CD9AC00087CE3A /* libz.dylib */; }; + 507B44301C336EFA0067B53E /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; + 507B44311C336EFA0067B53E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA28B18CD91510087CE3A /* Foundation.framework */; }; + 507B44321C336EFA0067B53E /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA35C18CD9A9E0087CE3A /* AudioToolbox.framework */; }; + 507B44331C336EFA0067B53E /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA35A18CD9A950087CE3A /* ApplicationServices.framework */; }; + 507B44341C336EFA0067B53E /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA35818CD9A8F0087CE3A /* OpenAL.framework */; }; + 507B44351C336EFA0067B53E /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA35618CD9A890087CE3A /* QuartzCore.framework */; }; + 507B44361C336EFA0067B53E /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA35418CD9A820087CE3A /* OpenGL.framework */; }; + 507B44471C3370050067B53E /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = 507B44451C3370050067B53E /* main.js */; }; + 507B44481C3370050067B53E /* project.json in Resources */ = {isa = PBXBuildFile; fileRef = 507B44461C3370050067B53E /* project.json */; }; 50921EAF1B746D5F00C085CC /* DownloaderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50921EAD1B746D5F00C085CC /* DownloaderTest.cpp */; }; 50921EB01B746D5F00C085CC /* DownloaderTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50921EAD1B746D5F00C085CC /* DownloaderTest.cpp */; }; + 50FC18521C3371C000DD15A3 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50FC17C51C3371C000DD15A3 /* AppDelegate.cpp */; }; + 50FC188C1C3371C000DD15A3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18211C3371C000DD15A3 /* InfoPlist.strings */; }; + 50FC188D1C3371C000DD15A3 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18231C3371C000DD15A3 /* MainMenu.xib */; }; + 50FC188E1C3371C000DD15A3 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18251C3371C000DD15A3 /* Icon.icns */; }; + 50FC188F1C3371C000DD15A3 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50FC18261C3371C000DD15A3 /* main.cpp */; }; + 50FC18B01C3371D400DD15A3 /* res in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18AE1C3371D400DD15A3 /* res */; }; + 50FC18B11C3371D400DD15A3 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18AF1C3371D400DD15A3 /* src */; }; + 50FC18B31C33720300DD15A3 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18B21C33720300DD15A3 /* script */; }; + 50FC18C31C33725200DD15A3 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 18FC4D5E1B4257CD00B76F95 /* libsqlite3.dylib */; }; + 50FC18C41C33725200DD15A3 /* libjscocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 185663101B41511B009EF2AE /* libjscocos2d iOS.a */; }; + 50FC18C51C33725200DD15A3 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52B47A331A534B2B004E4C60 /* Security.framework */; }; + 50FC18C61C33725200DD15A3 /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2d iOS.a */; }; + 50FC18C71C33725200DD15A3 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EA0FB65191B933000B170C8 /* MediaPlayer.framework */; }; + 50FC18C81C33725200DD15A3 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA3AF18CDA06D0087CE3A /* libz.dylib */; }; + 50FC18C91C33725200DD15A3 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = ED545A721B68A1AC00C3958E /* libiconv.dylib */; }; + 50FC18CA1C33725200DD15A3 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; }; + 50FC18CB1C33725200DD15A3 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA3A818CD9F130087CE3A /* AudioToolbox.framework */; }; + 50FC18CC1C33725200DD15A3 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA3A618CD9F0D0087CE3A /* OpenAL.framework */; }; + 50FC18CD1C33725200DD15A3 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA3A418CD9F060087CE3A /* QuartzCore.framework */; }; + 50FC18CE1C33725200DD15A3 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA3A218CD9EFE0087CE3A /* CoreGraphics.framework */; }; + 50FC18CF1C33725200DD15A3 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA3A018CD9EF60087CE3A /* OpenGLES.framework */; }; + 50FC18D01C33725200DD15A3 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA39E18CD9EE50087CE3A /* UIKit.framework */; }; + 50FC18D11C33725200DD15A3 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA39C18CD9ED80087CE3A /* AVFoundation.framework */; }; + 50FC18D21C33725200DD15A3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; + 50FC18E81C3372B300DD15A3 /* script in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18B21C33720300DD15A3 /* script */; }; + 50FC18E91C3372B900DD15A3 /* res in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18AE1C3371D400DD15A3 /* res */; }; + 50FC18EA1C3372B900DD15A3 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18AF1C3371D400DD15A3 /* src */; }; + 50FC18EB1C3372C700DD15A3 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50FC17C51C3371C000DD15A3 /* AppDelegate.cpp */; }; + 50FC18EC1C3372DB00DD15A3 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 50FC180C1C3371C000DD15A3 /* AppController.mm */; }; + 50FC18ED1C3372DB00DD15A3 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 50FC180D1C3371C000DD15A3 /* Default-568h@2x.png */; }; + 50FC18EE1C3372DB00DD15A3 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 50FC180E1C3371C000DD15A3 /* Default.png */; }; + 50FC18EF1C3372DB00DD15A3 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 50FC180F1C3371C000DD15A3 /* Default@2x.png */; }; + 50FC18F01C3372DB00DD15A3 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18101C3371C000DD15A3 /* Icon-114.png */; }; + 50FC18F11C3372DB00DD15A3 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18111C3371C000DD15A3 /* Icon-120.png */; }; + 50FC18F21C3372DB00DD15A3 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18121C3371C000DD15A3 /* Icon-144.png */; }; + 50FC18F31C3372DB00DD15A3 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18131C3371C000DD15A3 /* Icon-152.png */; }; + 50FC18F41C3372DB00DD15A3 /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18141C3371C000DD15A3 /* Icon-57.png */; }; + 50FC18F51C3372DB00DD15A3 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18151C3371C000DD15A3 /* Icon-72.png */; }; + 50FC18F61C3372DB00DD15A3 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18161C3371C000DD15A3 /* Icon-76.png */; }; + 50FC18F71C3372DB00DD15A3 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 50FC18171C3371C000DD15A3 /* Info.plist */; }; + 50FC18F81C3372DB00DD15A3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 50FC18181C3371C000DD15A3 /* main.m */; }; + 50FC18F91C3372DB00DD15A3 /* NativeOcClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 50FC181A1C3371C000DD15A3 /* NativeOcClass.m */; }; + 50FC18FA1C3372DB00DD15A3 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 50FC181D1C3371C000DD15A3 /* RootViewController.mm */; }; 527B1F3019EF9819000A1F82 /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 527B1F2E19EF9819000A1F82 /* Default-667h@2x.png */; }; 527B1F3119EF9819000A1F82 /* Default-736h@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 527B1F2F19EF9819000A1F82 /* Default-736h@3x.png */; }; 527B1F3419EF9CF8000A1F82 /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 527B1F3219EF9CF8000A1F82 /* Default-667h@2x.png */; }; @@ -1772,6 +1833,34 @@ remoteGlobalIDString = 507B39BF1C31BDD30067B53E; remoteInfo = "libcocos2d tvOS"; }; + 507B441C1C336EFA0067B53E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 185663081B41511B009EF2AE /* cocos2d_js_bindings.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = A03F31E81781479B006731B9; + remoteInfo = "libjscocos2d Mac"; + }; + 507B441E1C336EFA0067B53E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 1551A33E158F2AB200E66CFE; + remoteInfo = "cocos2dx Mac"; + }; + 50FC18B61C33725200DD15A3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 185663081B41511B009EF2AE /* cocos2d_js_bindings.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = A07A4FB5178387750073F6A7; + remoteInfo = "libjscocos2d iOS"; + }; + 50FC18B81C33725200DD15A3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = A07A4C241783777C0073F6A7; + remoteInfo = "cocos2dx iOS"; + }; A035ACBF178246BD00987F6C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; @@ -2520,8 +2609,42 @@ 507B42B01C31E6070067B53E /* js-tests tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "js-tests tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 507B43B91C31FB670067B53E /* lua-tests tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "lua-tests tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 507B43F21C3201360067B53E /* game-controller-test tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "game-controller-test tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 507B44431C336EFA0067B53E /* js-memory-gc-tests Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "js-memory-gc-tests Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 507B44451C3370050067B53E /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = main.js; path = "../tests/js-memory-gc-tests/main.js"; sourceTree = ""; }; + 507B44461C3370050067B53E /* project.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = project.json; path = "../tests/js-memory-gc-tests/project.json"; sourceTree = ""; }; 50921EAD1B746D5F00C085CC /* DownloaderTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloaderTest.cpp; sourceTree = ""; }; 50921EAE1B746D5F00C085CC /* DownloaderTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloaderTest.h; sourceTree = ""; }; + 50FC17C51C3371C000DD15A3 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; + 50FC17C61C3371C000DD15A3 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 50FC180B1C3371C000DD15A3 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; + 50FC180C1C3371C000DD15A3 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; + 50FC180D1C3371C000DD15A3 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 50FC180E1C3371C000DD15A3 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + 50FC180F1C3371C000DD15A3 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + 50FC18101C3371C000DD15A3 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; + 50FC18111C3371C000DD15A3 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; + 50FC18121C3371C000DD15A3 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; + 50FC18131C3371C000DD15A3 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; + 50FC18141C3371C000DD15A3 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; + 50FC18151C3371C000DD15A3 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; + 50FC18161C3371C000DD15A3 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; + 50FC18171C3371C000DD15A3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 50FC18181C3371C000DD15A3 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 50FC18191C3371C000DD15A3 /* NativeOcClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeOcClass.h; sourceTree = ""; }; + 50FC181A1C3371C000DD15A3 /* NativeOcClass.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeOcClass.m; sourceTree = ""; }; + 50FC181B1C3371C000DD15A3 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; + 50FC181C1C3371C000DD15A3 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; + 50FC181D1C3371C000DD15A3 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; + 50FC18221C3371C000DD15A3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 50FC18241C3371C000DD15A3 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; + 50FC18251C3371C000DD15A3 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; + 50FC18261C3371C000DD15A3 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 50FC18271C3371C000DD15A3 /* Test_Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Test_Info.plist; sourceTree = ""; }; + 50FC18281C3371C000DD15A3 /* Test_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Test_Prefix.pch; sourceTree = ""; }; + 50FC18AE1C3371D400DD15A3 /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; name = res; path = "../tests/js-memory-gc-tests/res"; sourceTree = ""; }; + 50FC18AF1C3371D400DD15A3 /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; name = src; path = "../tests/js-memory-gc-tests/src"; sourceTree = ""; }; + 50FC18B21C33720300DD15A3 /* script */ = {isa = PBXFileReference; lastKnownFileType = folder; name = script; path = "../cocos/scripting/js-bindings/script"; sourceTree = ""; }; + 50FC18E61C33725200DD15A3 /* js-memory-gc-tests iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "js-memory-gc-tests iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 527B1F2E19EF9819000A1F82 /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-667h@2x.png"; sourceTree = ""; }; 527B1F2F19EF9819000A1F82 /* Default-736h@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-736h@3x.png"; sourceTree = ""; }; 527B1F3219EF9CF8000A1F82 /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-667h@2x.png"; sourceTree = ""; }; @@ -2978,6 +3101,52 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 507B44261C336EFA0067B53E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 507B44271C336EFA0067B53E /* libsqlite3.dylib in Frameworks */, + 507B44281C336EFA0067B53E /* AppKit.framework in Frameworks */, + 507B44291C336EFA0067B53E /* Cocoa.framework in Frameworks */, + 507B442A1C336EFA0067B53E /* libcurl.dylib in Frameworks */, + 507B442B1C336EFA0067B53E /* libjscocos2d Mac.a in Frameworks */, + 507B442C1C336EFA0067B53E /* Security.framework in Frameworks */, + 507B442D1C336EFA0067B53E /* libiconv.dylib in Frameworks */, + 507B442E1C336EFA0067B53E /* libcocos2d Mac.a in Frameworks */, + 507B442F1C336EFA0067B53E /* libz.dylib in Frameworks */, + 507B44301C336EFA0067B53E /* IOKit.framework in Frameworks */, + 507B44311C336EFA0067B53E /* Foundation.framework in Frameworks */, + 507B44321C336EFA0067B53E /* AudioToolbox.framework in Frameworks */, + 507B44331C336EFA0067B53E /* ApplicationServices.framework in Frameworks */, + 507B44341C336EFA0067B53E /* OpenAL.framework in Frameworks */, + 507B44351C336EFA0067B53E /* QuartzCore.framework in Frameworks */, + 507B44361C336EFA0067B53E /* OpenGL.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 50FC18C21C33725200DD15A3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 50FC18C31C33725200DD15A3 /* libsqlite3.dylib in Frameworks */, + 50FC18C41C33725200DD15A3 /* libjscocos2d iOS.a in Frameworks */, + 50FC18C51C33725200DD15A3 /* Security.framework in Frameworks */, + 50FC18C61C33725200DD15A3 /* libcocos2d iOS.a in Frameworks */, + 50FC18C71C33725200DD15A3 /* MediaPlayer.framework in Frameworks */, + 50FC18C81C33725200DD15A3 /* libz.dylib in Frameworks */, + 50FC18C91C33725200DD15A3 /* libiconv.dylib in Frameworks */, + 50FC18CA1C33725200DD15A3 /* CoreMotion.framework in Frameworks */, + 50FC18CB1C33725200DD15A3 /* AudioToolbox.framework in Frameworks */, + 50FC18CC1C33725200DD15A3 /* OpenAL.framework in Frameworks */, + 50FC18CD1C33725200DD15A3 /* QuartzCore.framework in Frameworks */, + 50FC18CE1C33725200DD15A3 /* CoreGraphics.framework in Frameworks */, + 50FC18CF1C33725200DD15A3 /* OpenGLES.framework in Frameworks */, + 50FC18D01C33725200DD15A3 /* UIKit.framework in Frameworks */, + 50FC18D11C33725200DD15A3 /* AVFoundation.framework in Frameworks */, + 50FC18D21C33725200DD15A3 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; A07A52171783A1D20073F6A7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -3236,6 +3405,8 @@ 507B42B01C31E6070067B53E /* js-tests tvOS.app */, 507B43B91C31FB670067B53E /* lua-tests tvOS.app */, 507B43F21C3201360067B53E /* game-controller-test tvOS.app */, + 507B44431C336EFA0067B53E /* js-memory-gc-tests Mac.app */, + 50FC18E61C33725200DD15A3 /* js-memory-gc-tests iOS.app */, ); name = Products; sourceTree = ""; @@ -4579,6 +4750,7 @@ 1AC35E0318CEE78300F37B72 /* tests */ = { isa = PBXGroup; children = ( + 507B44491C3370140067B53E /* js-memory-gc-tests */, 185663411B41553A009EF2AE /* js-tests */, 15CBA087196EE66D005877BB /* lua-game-controller-test */, 3E6176B51960FA6300DE83F5 /* game-controller-test */, @@ -5124,6 +5296,19 @@ path = MaterialSystemTest; sourceTree = ""; }; + 507B44491C3370140067B53E /* js-memory-gc-tests */ = { + isa = PBXGroup; + children = ( + 50FC18B21C33720300DD15A3 /* script */, + 50FC18AE1C3371D400DD15A3 /* res */, + 50FC18AF1C3371D400DD15A3 /* src */, + 50FC17C31C3371C000DD15A3 /* project */, + 507B44451C3370050067B53E /* main.js */, + 507B44461C3370050067B53E /* project.json */, + ); + name = "js-memory-gc-tests"; + sourceTree = ""; + }; 50921EAC1B746D5F00C085CC /* DownloaderTest */ = { isa = PBXGroup; children = ( @@ -5133,6 +5318,65 @@ path = DownloaderTest; sourceTree = ""; }; + 50FC17C31C3371C000DD15A3 /* project */ = { + isa = PBXGroup; + children = ( + 50FC17C41C3371C000DD15A3 /* Classes */, + 50FC180A1C3371C000DD15A3 /* proj.ios */, + 50FC18201C3371C000DD15A3 /* proj.mac */, + ); + name = project; + path = "../tests/js-memory-gc-tests/project"; + sourceTree = ""; + }; + 50FC17C41C3371C000DD15A3 /* Classes */ = { + isa = PBXGroup; + children = ( + 50FC17C51C3371C000DD15A3 /* AppDelegate.cpp */, + 50FC17C61C3371C000DD15A3 /* AppDelegate.h */, + ); + path = Classes; + sourceTree = ""; + }; + 50FC180A1C3371C000DD15A3 /* proj.ios */ = { + isa = PBXGroup; + children = ( + 50FC180B1C3371C000DD15A3 /* AppController.h */, + 50FC180C1C3371C000DD15A3 /* AppController.mm */, + 50FC180D1C3371C000DD15A3 /* Default-568h@2x.png */, + 50FC180E1C3371C000DD15A3 /* Default.png */, + 50FC180F1C3371C000DD15A3 /* Default@2x.png */, + 50FC18101C3371C000DD15A3 /* Icon-114.png */, + 50FC18111C3371C000DD15A3 /* Icon-120.png */, + 50FC18121C3371C000DD15A3 /* Icon-144.png */, + 50FC18131C3371C000DD15A3 /* Icon-152.png */, + 50FC18141C3371C000DD15A3 /* Icon-57.png */, + 50FC18151C3371C000DD15A3 /* Icon-72.png */, + 50FC18161C3371C000DD15A3 /* Icon-76.png */, + 50FC18171C3371C000DD15A3 /* Info.plist */, + 50FC18181C3371C000DD15A3 /* main.m */, + 50FC18191C3371C000DD15A3 /* NativeOcClass.h */, + 50FC181A1C3371C000DD15A3 /* NativeOcClass.m */, + 50FC181B1C3371C000DD15A3 /* Prefix.pch */, + 50FC181C1C3371C000DD15A3 /* RootViewController.h */, + 50FC181D1C3371C000DD15A3 /* RootViewController.mm */, + ); + path = proj.ios; + sourceTree = ""; + }; + 50FC18201C3371C000DD15A3 /* proj.mac */ = { + isa = PBXGroup; + children = ( + 50FC18211C3371C000DD15A3 /* InfoPlist.strings */, + 50FC18231C3371C000DD15A3 /* MainMenu.xib */, + 50FC18251C3371C000DD15A3 /* Icon.icns */, + 50FC18261C3371C000DD15A3 /* main.cpp */, + 50FC18271C3371C000DD15A3 /* Test_Info.plist */, + 50FC18281C3371C000DD15A3 /* Test_Prefix.pch */, + ); + path = proj.mac; + sourceTree = ""; + }; 6886696E1AE8E8A000C2CFD9 /* SpritePolygonTest */ = { isa = PBXGroup; children = ( @@ -5650,6 +5894,46 @@ productReference = 507B43F21C3201360067B53E /* game-controller-test tvOS.app */; productType = "com.apple.product-type.application"; }; + 507B441A1C336EFA0067B53E /* js-memory-gc-tests Mac */ = { + isa = PBXNativeTarget; + buildConfigurationList = 507B44401C336EFA0067B53E /* Build configuration list for PBXNativeTarget "js-memory-gc-tests Mac" */; + buildPhases = ( + 507B441F1C336EFA0067B53E /* ShellScript */, + 507B44201C336EFA0067B53E /* Sources */, + 507B44261C336EFA0067B53E /* Frameworks */, + 507B44371C336EFA0067B53E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 507B441B1C336EFA0067B53E /* PBXTargetDependency */, + 507B441D1C336EFA0067B53E /* PBXTargetDependency */, + ); + name = "js-memory-gc-tests Mac"; + productName = "Test lua Mac"; + productReference = 507B44431C336EFA0067B53E /* js-memory-gc-tests Mac.app */; + productType = "com.apple.product-type.application"; + }; + 50FC18B41C33725200DD15A3 /* js-memory-gc-tests iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 50FC18E31C33725200DD15A3 /* Build configuration list for PBXNativeTarget "js-memory-gc-tests iOS" */; + buildPhases = ( + 50FC18B91C33725200DD15A3 /* ShellScript */, + 50FC18BA1C33725200DD15A3 /* Sources */, + 50FC18C21C33725200DD15A3 /* Frameworks */, + 50FC18D31C33725200DD15A3 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 50FC18B51C33725200DD15A3 /* PBXTargetDependency */, + 50FC18B71C33725200DD15A3 /* PBXTargetDependency */, + ); + name = "js-memory-gc-tests iOS"; + productName = "Test lua iOS"; + productReference = 50FC18E61C33725200DD15A3 /* js-memory-gc-tests iOS.app */; + productType = "com.apple.product-type.application"; + }; A07A517F1783A1D20073F6A7 /* cpp-tests iOS */ = { isa = PBXNativeTarget; buildConfigurationList = A07A52261783A1D20073F6A7 /* Build configuration list for PBXNativeTarget "cpp-tests iOS" */; @@ -5768,6 +6052,7 @@ 1ABCA28518CD91510087CE3A /* lua-tests Mac */, 1A0EE2B818CDF733004CD58F /* lua-empty-test Mac */, 1856634B1B4155D3009EF2AE /* js-tests Mac */, + 507B441A1C336EFA0067B53E /* js-memory-gc-tests Mac */, FA94B0C01B8EF76D0074B261 /* performance-tests Mac */, A07A517B1783A1CC0073F6A7 /* build all tests iOS */, A07A517F1783A1D20073F6A7 /* cpp-tests iOS */, @@ -5777,6 +6062,7 @@ 3E6176FF1960FAED00DE83F5 /* game-controller-test IOS */, 15CBA015196EE56C005877BB /* lua-game-controller-test iOS */, 185663961B4155DD009EF2AE /* js-tests iOS */, + 50FC18B41C33725200DD15A3 /* js-memory-gc-tests iOS */, FA94AF961B8EF69A0074B261 /* performance-tests iOS */, 507B43541C31FB340067B53E /* build all tests tvOS */, 507B40FE1C31BEA60067B53E /* cpp-tests tvOS */, @@ -6338,6 +6624,42 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 507B44371C336EFA0067B53E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 50FC18B11C3371D400DD15A3 /* src in Resources */, + 50FC188D1C3371C000DD15A3 /* MainMenu.xib in Resources */, + 50FC18B01C3371D400DD15A3 /* res in Resources */, + 50FC18B31C33720300DD15A3 /* script in Resources */, + 50FC188E1C3371C000DD15A3 /* Icon.icns in Resources */, + 507B44471C3370050067B53E /* main.js in Resources */, + 50FC188C1C3371C000DD15A3 /* InfoPlist.strings in Resources */, + 507B44481C3370050067B53E /* project.json in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 50FC18D31C33725200DD15A3 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 50FC18F11C3372DB00DD15A3 /* Icon-120.png in Resources */, + 50FC18F61C3372DB00DD15A3 /* Icon-76.png in Resources */, + 50FC18EF1C3372DB00DD15A3 /* Default@2x.png in Resources */, + 50FC18EA1C3372B900DD15A3 /* src in Resources */, + 50FC18F31C3372DB00DD15A3 /* Icon-152.png in Resources */, + 50FC18ED1C3372DB00DD15A3 /* Default-568h@2x.png in Resources */, + 50FC18F71C3372DB00DD15A3 /* Info.plist in Resources */, + 50FC18F51C3372DB00DD15A3 /* Icon-72.png in Resources */, + 50FC18E81C3372B300DD15A3 /* script in Resources */, + 50FC18F01C3372DB00DD15A3 /* Icon-114.png in Resources */, + 50FC18E91C3372B900DD15A3 /* res in Resources */, + 50FC18F21C3372DB00DD15A3 /* Icon-144.png in Resources */, + 50FC18F41C3372DB00DD15A3 /* Icon-57.png in Resources */, + 50FC18EE1C3372DB00DD15A3 /* Default.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; A07A518A1783A1D20073F6A7 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -6613,6 +6935,32 @@ shellPath = /bin/sh; shellScript = "#!/bin/bash\ncocos_dir=${SRCROOT}/../tests/lua-tests/src/cocos\nif [ -d \"${cocos_dir}\" ]; then\nrm -rv \"${cocos_dir}\"\nmkdir \"${cocos_dir}\"\nelse\nmkdir \"${cocos_dir}\"\nfi\n\ncp -r \"${SRCROOT}/../cocos/scripting/lua-bindings/script/\" \"${cocos_dir}\""; }; + 507B441F1C336EFA0067B53E /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "#!/bin/bash\ncocos_dir=${SRCROOT}/../tests/js-tests/res\nif [ -d \"${cocos_dir}\" ]; then\nrm -rv \"${cocos_dir}\"\nmkdir \"${cocos_dir}\"\nelse\nmkdir \"${cocos_dir}\"\nfi\n\ncp -r \"${SRCROOT}/../tests/cpp-tests/Resources/\" \"${cocos_dir}\"\ncp -r \"${SRCROOT}/../tests/js-tests/resjs/\" \"${cocos_dir}/resjs\""; + }; + 50FC18B91C33725200DD15A3 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "#!/bin/bash\ncocos_dir=${SRCROOT}/../tests/js-tests/res\nif [ -d \"${cocos_dir}\" ]; then\nrm -rv \"${cocos_dir}\"\nmkdir \"${cocos_dir}\"\nelse\nmkdir \"${cocos_dir}\"\nfi\n\ncp -r \"${SRCROOT}/../tests/cpp-tests/Resources/\" \"${cocos_dir}\"\ncp -r \"${SRCROOT}/../tests/js-tests/resjs/\" \"${cocos_dir}/resjs\""; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -7165,6 +7513,27 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 507B44201C336EFA0067B53E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 50FC188F1C3371C000DD15A3 /* main.cpp in Sources */, + 50FC18521C3371C000DD15A3 /* AppDelegate.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 50FC18BA1C33725200DD15A3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 50FC18EB1C3372C700DD15A3 /* AppDelegate.cpp in Sources */, + 50FC18FA1C3372DB00DD15A3 /* RootViewController.mm in Sources */, + 50FC18F91C3372DB00DD15A3 /* NativeOcClass.m in Sources */, + 50FC18F81C3372DB00DD15A3 /* main.m in Sources */, + 50FC18EC1C3372DB00DD15A3 /* AppController.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; A07A51AD1783A1D20073F6A7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -7603,6 +7972,26 @@ name = "libcocos2d tvOS"; targetProxy = 507B43F71C3202300067B53E /* PBXContainerItemProxy */; }; + 507B441B1C336EFA0067B53E /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "libjscocos2d Mac"; + targetProxy = 507B441C1C336EFA0067B53E /* PBXContainerItemProxy */; + }; + 507B441D1C336EFA0067B53E /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "cocos2dx Mac"; + targetProxy = 507B441E1C336EFA0067B53E /* PBXContainerItemProxy */; + }; + 50FC18B51C33725200DD15A3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "libjscocos2d iOS"; + targetProxy = 50FC18B61C33725200DD15A3 /* PBXContainerItemProxy */; + }; + 50FC18B71C33725200DD15A3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "cocos2dx iOS"; + targetProxy = 50FC18B81C33725200DD15A3 /* PBXContainerItemProxy */; + }; A035ACC0178246BD00987F6C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 1D6058900D05DD3D006BFB54 /* cpp-tests Mac */; @@ -7706,6 +8095,22 @@ name = MainMenu.xib; sourceTree = ""; }; + 50FC18211C3371C000DD15A3 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 50FC18221C3371C000DD15A3 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 50FC18231C3371C000DD15A3 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 50FC18241C3371C000DD15A3 /* en */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -8446,6 +8851,139 @@ }; name = Release; }; + 507B44411C336EFA0067B53E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + CC_TARGET_OS_MAC, + CC_KEYBOARD_SUPPORT, + COCOS2D_JAVASCRIPT, + ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + INFOPLIST_FILE = "$(SRCROOT)/../tests/js-memory-gc-tests/project/proj.mac/Test_Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.7; + OTHER_LDFLAGS = ( + "-pagezero_size", + 10000, + "-image_base", + 100000000, + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.cocos2d-x.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual"; + }; + name = Debug; + }; + 507B44421C336EFA0067B53E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + CC_TARGET_OS_MAC, + CC_KEYBOARD_SUPPORT, + COCOS2D_JAVASCRIPT, + ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + INFOPLIST_FILE = "$(SRCROOT)/../tests/js-memory-gc-tests/project/proj.mac/Test_Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.7; + OTHER_LDFLAGS = ( + "-pagezero_size", + 10000, + "-image_base", + 100000000, + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.cocos2d-x.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/spidermonkey/include/mac $(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 50FC18E41C33725200DD15A3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_BITCODE = NO; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + CC_TARGET_OS_IPHONE, + COCOS2D_JAVASCRIPT, + ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + INFOPLIST_FILE = "$(SRCROOT)/../tests/js-memory-gc-tests/project/proj.ios/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + LIBRARY_SEARCH_PATHS = ( + "$(SRCROOT)/../external/curl/prebuilt/ios", + "/Users/cocos2d/MyWork/cocos2d-x-develop/external/curl/prebuilt/ios", + ); + MACOSX_DEPLOYMENT_TARGET = 10.10; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocos2d-x.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual $(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external/spidermonkey/include/ios $(SRCROOT)/../external/curl/include/ios"; + VALID_ARCHS = "arm64 armv7"; + }; + name = Debug; + }; + 50FC18E51C33725200DD15A3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_BITCODE = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + CC_TARGET_OS_IPHONE, + COCOS2D_JAVASCRIPT, + ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + INFOPLIST_FILE = "$(SRCROOT)/../tests/js-memory-gc-tests/project/proj.ios/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + LIBRARY_SEARCH_PATHS = ( + "$(SRCROOT)/../external/curl/prebuilt/ios", + "/Users/cocos2d/MyWork/cocos2d-x-develop/external/curl/prebuilt/ios", + ); + MACOSX_DEPLOYMENT_TARGET = 10.10; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocos2d-x.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual $(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external/spidermonkey/include/ios $(SRCROOT)/../external/curl/include/ios"; + VALIDATE_PRODUCT = YES; + VALID_ARCHS = "arm64 armv7"; + }; + name = Release; + }; A035ACBD1782469800987F6C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -8832,6 +9370,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; + 507B44401C336EFA0067B53E /* Build configuration list for PBXNativeTarget "js-memory-gc-tests Mac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 507B44411C336EFA0067B53E /* Debug */, + 507B44421C336EFA0067B53E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + 50FC18E31C33725200DD15A3 /* Build configuration list for PBXNativeTarget "js-memory-gc-tests iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 50FC18E41C33725200DD15A3 /* Debug */, + 50FC18E51C33725200DD15A3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; A035ACBC1782469800987F6C /* Build configuration list for PBXAggregateTarget "build all tests Mac" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-memory-gc-tests Mac.xcscheme b/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-memory-gc-tests Mac.xcscheme new file mode 100644 index 0000000000..0f8a35ee14 --- /dev/null +++ b/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-memory-gc-tests Mac.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-memory-gc-tests iOS.xcscheme b/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-memory-gc-tests iOS.xcscheme new file mode 100644 index 0000000000..46fa5e14c9 --- /dev/null +++ b/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-memory-gc-tests iOS.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-tests-memory-gc Mac.xcscheme b/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-tests-memory-gc Mac.xcscheme new file mode 100644 index 0000000000..5733b208e8 --- /dev/null +++ b/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-tests-memory-gc Mac.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-tests-memory-gc iOS.xcscheme b/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-tests-memory-gc iOS.xcscheme new file mode 100644 index 0000000000..ac1ed9615f --- /dev/null +++ b/build/cocos2d_tests.xcodeproj/xcshareddata/xcschemes/js-tests-memory-gc iOS.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 8851f9996a..1c6586d508 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -323,7 +323,7 @@ Sprite::Sprite(void) #endif //CC_SPRITE_DEBUG_DRAW } -Sprite::~Sprite(void) +Sprite::~Sprite() { CC_SAFE_RELEASE(_spriteFrame); CC_SAFE_RELEASE(_texture); diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index 1bb3fc785f..705f55953d 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -71,7 +71,7 @@ TransitionScene * TransitionScene::create(float t, Scene *scene) bool TransitionScene::initWithDuration(float t, Scene *scene) { - CCASSERT( scene != nullptr, "Argument scene must be non-nil"); + CCASSERT(scene != nullptr, "Argument scene must be non-nil"); if (Scene::init()) { diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index b7a3bb8635..9ca06869ff 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -1063,6 +1063,10 @@ void Director::setNextScene() { _runningScene->onEnter(); _runningScene->onEnterTransitionDidFinish(); + +#if CC_ENABLE_SCRIPT_BINDING + ScriptEngineManager::getInstance()->getScriptEngine()->garbageCollect(); +#endif // CC_ENABLE_SCRIPT_BINDING } } diff --git a/cocos/base/CCRef.cpp b/cocos/base/CCRef.cpp index eed860e602..40821905e7 100644 --- a/cocos/base/CCRef.cpp +++ b/cocos/base/CCRef.cpp @@ -34,10 +34,6 @@ THE SOFTWARE. NS_CC_BEGIN -// EXPERIMENTAL: Enable this in order to get rid of retain/release -// when using the Garbage Collector -#define CC_ENABLE_GC_FOR_NATIVE_OBJECTS 0 - #if CC_REF_LEAK_DETECTION static void trackRef(Ref* ref); static void untrackRef(Ref* ref); diff --git a/cocos/base/CCScriptSupport.h b/cocos/base/CCScriptSupport.h index d525744e3e..57e0b65244 100644 --- a/cocos/base/CCScriptSupport.h +++ b/cocos/base/CCScriptSupport.h @@ -761,6 +761,9 @@ public: It tells the Garbage Collector that the associated Scripting object can be collected */ virtual void unrootObject(Ref* obj) {} + + /** Triggers the garbage collector */ + virtual void garbageCollect() {} }; class Node; diff --git a/cocos/base/ccConfig.h b/cocos/base/ccConfig.h index 56ad72fb48..573c13a19e 100644 --- a/cocos/base/ccConfig.h +++ b/cocos/base/ccConfig.h @@ -329,6 +329,17 @@ THE SOFTWARE. #define CC_ENABLE_SCRIPT_BINDING 1 #endif +/** When CC_ENABLE_SCRIPT_BINDING and CC_ENABLE_GC_FOR_NATIVE_OBJECTS are both 1 + then the Garbage collector will will release the native objects, only when the JS/Lua objets + are collected. + The benefit is that users don't need to retain/release the JS/Lua objects manually. + + By default this behavior is disabled by default + */ +#ifndef CC_ENABLE_GC_FOR_NATIVE_OBJECTS +#define CC_ENABLE_GC_FOR_NATIVE_OBJECTS 0 +#endif + /** @def CC_CONSTRUCTOR_ACCESS * Indicate the init functions access modifier. If value equals to protected, then these functions are protected. * If value equals to public, these functions are public, diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 04a29dd4af..6318e02c63 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -76,10 +76,6 @@ #define BYTE_CODE_FILE_EXT ".jsc" -// EXPERIMENTAL: Enable this in order to get rid of retain/release -// when using the Garbage Collector -#define CC_ENABLE_GC_FOR_NATIVE_OBJECTS 0 - using namespace cocos2d; static std::string inData; @@ -98,17 +94,21 @@ static void serverEntryPoint(unsigned int port); std::unordered_map _js_global_type_map; static std::unordered_map _native_js_global_map; static std::unordered_map _js_native_global_map; - +static std::unordered_map _extended_objects_map; static char *_js_log_buf = NULL; static std::vector registrationList; + // name ~> JSScript map static std::unordered_map filename_script; // port ~> socket map static std::unordered_map ports_sockets; +// forward declarations +static void js_register_nativefinalizeme(JSContext *cx, JS::HandleObject global); + static void cc_closesocket(int fd) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) @@ -437,6 +437,8 @@ void registerDefaultClasses(JSContext* cx, JS::HandleObject global) { JS_DefineFunction(cx, global, "__restartVM", JSB_core_restartVM, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, global, "__cleanScript", JSB_cleanScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__isObjectValid", ScriptingCore::isObjectValid, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + js_register_nativefinalizeme(cx, jsc); } static void sc_finalize(JSFreeOp *freeOp, JSObject *obj) @@ -459,6 +461,92 @@ static const JSClass global_class = { JS_GlobalObjectTraceHook }; +static JSClass *jsb_nativefinalizeme_class; +static JSObject *jsb_nativefinalizeme_prototype; + +static bool js_nativefinalizeme_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + +#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS + + if (argc == 1) + { + auto extendedjsobj = args.get(0).toObjectOrNull(); + if (extendedjsobj) + { + JS::RootedObject proto(cx, jsb_nativefinalizeme_prototype); + JS::RootedObject obj(cx, JS_NewObject(cx, jsb_nativefinalizeme_class, proto, JS::NullPtr())); + args.rval().set(OBJECT_TO_JSVAL(obj)); + + if (_extended_objects_map.find(obj.get()) == _extended_objects_map.end()) + _extended_objects_map[obj.get()] = extendedjsobj; + else CCLOG("js_nativefinalizeme_constructor: obj = %p already added. ERROR! IMPOSSIBLE!", obj.get()); + return true; + } + } + CCLOG("js_nativefinalizeme_constructor: Invalid arguments"); + return false; + +#else // ! CC_ENABLE_GC_FOR_NATIVE_OBJECTS + // Don't create object if not using GC + args.rval().set(JS::NullValue()); + return true; +#endif +} + +static void js_nativefinalizeme_finalize(JSFreeOp* fop, JSObject* obj) +{ + auto it = _extended_objects_map.find(obj); + if (it != _extended_objects_map.end()) + { + auto extendedObj = it->second; + + // XXX: Only works for "ref" subclasses. + jsb_ref_finalize(fop, extendedObj); + + _extended_objects_map.erase(it); + } + else CCLOG("js_nativefinalizeme_finalize: obj = %p not found. ERROR!", obj); +} + +static void js_register_nativefinalizeme(JSContext *cx, JS::HandleObject global) +{ + jsb_nativefinalizeme_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_nativefinalizeme_class->name = "NativeFinalizeMe"; + jsb_nativefinalizeme_class->addProperty = JS_PropertyStub; + jsb_nativefinalizeme_class->delProperty = JS_DeletePropertyStub; + jsb_nativefinalizeme_class->getProperty = JS_PropertyStub; + jsb_nativefinalizeme_class->setProperty = JS_StrictPropertyStub; + jsb_nativefinalizeme_class->enumerate = JS_EnumerateStub; + jsb_nativefinalizeme_class->resolve = JS_ResolveStub; + jsb_nativefinalizeme_class->convert = JS_ConvertStub; + jsb_nativefinalizeme_class->finalize = js_nativefinalizeme_finalize; + jsb_nativefinalizeme_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + jsb_nativefinalizeme_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), + jsb_nativefinalizeme_class, + js_nativefinalizeme_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); +} + ScriptingCore* ScriptingCore::getInstance() { static ScriptingCore* instance = nullptr; @@ -1207,7 +1295,7 @@ bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::Eve for (const auto& touch : touches) { - JS::RootedValue jsret(_cx, OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, touch, typeClassTouch, "cocos2d::Touch"))); + JS::RootedValue jsret(_cx, OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(_cx, touch, typeClassTouch, "cocos2d::Touch"))); if (!JS_SetElement(this->_cx, jsretArr, count, jsret)) { break; @@ -1220,7 +1308,7 @@ bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::Eve { jsval dataVal[2]; dataVal[0] = OBJECT_TO_JSVAL(jsretArr); - dataVal[1] = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, event, typeClassEvent, "cocos2d::Event")); + dataVal[1] = OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(_cx, event, typeClassEvent, "cocos2d::Event")); ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet); } @@ -1254,8 +1342,8 @@ bool ScriptingCore::handleTouchEvent(void* nativeObj, cocos2d::EventTouch::Event js_type_class_t *typeClassEvent = js_get_type_from_native(event); jsval dataVal[2]; - dataVal[0] = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, touch, typeClassTouch, "cocos2d::Touch")); - dataVal[1] = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, event, typeClassEvent, "cocos2d::Event")); + dataVal[0] = OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(_cx, touch, typeClassTouch, "cocos2d::Touch")); + dataVal[1] = OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(_cx, event, typeClassEvent, "cocos2d::Event")); ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet); } @@ -1283,7 +1371,7 @@ bool ScriptingCore::handleMouseEvent(void* nativeObj, cocos2d::EventMouse::Mouse if (p) { js_type_class_t *typeClass = js_get_type_from_native(event); - jsval dataVal = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, event, typeClass, "cocos2d::Event")); + jsval dataVal = OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(_cx, event, typeClass, "cocos2d::Event")); ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 1, &dataVal, jsvalRet); removeJSObject(_cx, event); @@ -1375,7 +1463,7 @@ bool ScriptingCore::handleKeybardEvent(void* nativeObj, cocos2d::EventKeyboard:: js_type_class_t *typeClass = js_get_type_from_native(event); jsval args[2] = { int32_to_jsval(_cx, (int32_t)keyCode), - OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, event, typeClass, "cocos2d::Event")) + OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(_cx, event, typeClass, "cocos2d::Event")) }; if (isPressed) @@ -1404,8 +1492,8 @@ bool ScriptingCore::handleFocusEvent(void* nativeObj, cocos2d::ui::Widget* widge js_type_class_t *typeClass = js_get_type_from_native(widgetLoseFocus); jsval args[2] = { - OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, widgetLoseFocus, typeClass, "cocos2d::ui::Widget")), - OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, widgetGetFocus, typeClass, "cocos2d::ui::Widget")) + OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(_cx, widgetLoseFocus, typeClass, "cocos2d::ui::Widget")), + OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(_cx, widgetGetFocus, typeClass, "cocos2d::ui::Widget")) }; bool ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onFocusChanged", 2, args); @@ -1426,7 +1514,7 @@ int ScriptingCore::executeCustomTouchesEvent(EventTouch::EventCode eventType, { js_type_class_t *typeClass = js_get_type_from_native(touch); - jsval jsret = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(this->_cx, touch, typeClass, "cocos2d::Touch")); + jsval jsret = OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(this->_cx, touch, typeClass, "cocos2d::Touch")); JS::RootedValue jsval(_cx, jsret); if (!JS_SetElement(this->_cx, jsretArr, count, jsval)) { break; @@ -1455,7 +1543,7 @@ int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, Touc std::string funcName = getTouchFuncName(eventType); js_type_class_t *typeClass = js_get_type_from_native(touch); - jsval jsTouch = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(this->_cx, touch, typeClass, "cocos2d::Touch")); + jsval jsTouch = OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(this->_cx, touch, typeClass, "cocos2d::Touch")); executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, &retval); @@ -1476,7 +1564,7 @@ int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, std::string funcName = getTouchFuncName(eventType); js_type_class_t *typeClass = js_get_type_from_native(touch); - jsval jsTouch = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(this->_cx, touch, typeClass, "cocos2d::Touch")); + jsval jsTouch = OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(this->_cx, touch, typeClass, "cocos2d::Touch")); executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, retval); @@ -1576,7 +1664,7 @@ void ScriptingCore::rootObject(Ref* ref) JS::AddNamedObjectRoot(cx, &proxy->obj, typeid(*ref).name()); ref->_rooted = true; } - else CCLOG("rootObject: BUG. native not found: %p", ref); + else CCLOG("rootObject: BUG. native not found: %p (%s)", ref, typeid(*ref).name()); } void ScriptingCore::unrootObject(Ref* ref) @@ -1587,7 +1675,19 @@ void ScriptingCore::unrootObject(Ref* ref) JS::RemoveObjectRoot(cx, &proxy->obj); ref->_rooted = false; } - else CCLOG("unrootObject: BUG. native not found: %p", ref); + else CCLOG("unrootObject: BUG. native not found: %p (%s)", ref, typeid(*ref).name()); +} + +void ScriptingCore::garbageCollect() +{ +#if CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 + auto runtime = JS_GetRuntime(_cx); + // twice: yep, call it twice since this is a generational GC + // and we want to collect as much as possible when this is being called + // from replaceScene(). + JS_GC(runtime); + JS_GC(runtime); +#endif } #pragma mark - Debug @@ -2029,11 +2129,13 @@ JSObject* jsb_ref_autoreleased_create_jsobject(JSContext *cx, cocos2d::Ref *ref, } // get_or_create -JSObject* jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug) +JS::HandleObject jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug) { auto proxy = jsb_get_native_proxy(ref); - if (proxy) - return proxy->obj; + if (proxy) { + JS::RootedObject obj(cx, proxy->obj); + return obj; + } // don't auto-release, don't retain. JS::RootedObject proto(cx, typeClass->proto.ref()); @@ -2055,6 +2157,30 @@ JSObject* jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_ty return js_obj; } +// get_or_create: when native object isn't a ref object or when the native object life cycle don't need to be managed by js object +JS::HandleObject jsb_get_or_create_weak_jsobject(JSContext *cx, void *native, js_type_class_t *typeClass, const char* debug) +{ + auto proxy = jsb_get_native_proxy(native); + if (proxy) + { + JS::RootedObject obj(cx, proxy->obj); + return obj; + } + + // don't auto-release, don't retain. + JS::RootedObject proto(cx, typeClass->proto.ref()); + JS::RootedObject parent(cx, typeClass->parentProto.ref()); + JS::RootedObject jsObj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + proxy = jsb_new_proxy(native, jsObj); + +#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS + // do nothing +#else + JS::AddNamedObjectRoot(cx, &proxy->obj, debug); +#endif // CC_ENABLE_GC_FOR_NATIVE_OBJECTS + return jsObj; +} + // get_or_create: REf is already autoreleased (or created) JSObject* jsb_ref_autoreleased_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug) { @@ -2105,14 +2231,14 @@ void jsb_ref_finalize(JSFreeOp* fop, JSObject* obj) if (proxy) { auto ref = static_cast(proxy->ptr); + + CCLOG("jsb_ref_finalize: %s", typeid(*ref).name()); + jsb_remove_proxy(proxy); if (ref) ref->release(); } - else - { - CCLOG("jsb_ref_finalize: BUG: proxy not found for %p (%s)", obj, JS_GetClass(obj)->name); - } +// else CCLOG("jsb_ref_finalize: BUG: proxy not found for %p (%s)", obj, JS_GetClass(obj)->name); #else // CCLOG("jsb_ref_finalize: JSObject address = %p", obj); #endif @@ -2121,6 +2247,8 @@ void jsb_ref_finalize(JSFreeOp* fop, JSObject* obj) // rebind void jsb_ref_rebind(JSContext* cx, JS::HandleObject jsobj, js_proxy_t *proxy, cocos2d::Ref* oldRef, cocos2d::Ref* newRef, const char* debug) { + oldRef->_scriptOwned = false; + #if not CC_ENABLE_GC_FOR_NATIVE_OBJECTS JS::RemoveObjectRoot(cx, &proxy->obj); #endif diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index bb03a5fac8..96d24c3ea9 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -508,6 +508,11 @@ public: */ virtual void unrootObject(cocos2d::Ref* ref) override; + /** + * Calls the Garbage Collector + */ + virtual void garbageCollect() override; + private: void string_report(JS::HandleValue val); void initRegister(); @@ -616,7 +621,7 @@ JSObject* jsb_ref_autoreleased_create_jsobject(JSContext *cx, cocos2d::Ref *ref, If it can't find it, it will create a new one associating it to Ref. Call this function for objects that were already created and initialized, when returning `getChild()` */ -JSObject* jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug); +JS::HandleObject jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug); /** It will try to get the associated JSObjct for ref. @@ -625,4 +630,7 @@ JSObject* jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_ty */ JSObject* jsb_ref_autoreleased_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug); + +JS::HandleObject jsb_get_or_create_weak_jsobject(JSContext *cx, void *native, js_type_class_t *typeClass, const char* debug); + #endif /* __SCRIPTING_CORE_H__ */ diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 66fdd989c3..a111f12826 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -2446,7 +2446,10 @@ bool js_cocos2dx_ActionInterval_repeat(JSContext *cx, uint32_t argc, jsval *vp) if (timesInt <= 0) { JS_ReportError(cx, "js_cocos2dx_ActionInterval_repeat : Repeat times must be greater than 0"); } - + + // no longer owned since it will be re-bound + cobj->_scriptOwned = false; + cocos2d::Repeat* action = new (std::nothrow) cocos2d::Repeat; action->initWithAction(cobj, timesInt); jsb_ref_rebind(cx, obj, proxy, cobj, action, "cocos2d::Repeat"); @@ -2468,10 +2471,15 @@ bool js_cocos2dx_ActionInterval_repeatForever(JSContext *cx, uint32_t argc, jsva JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionInterval_repeatForever : Invalid Native Object"); if (argc == 0) { + + // no longer owned. + cobj->_scriptOwned = false; + cocos2d::RepeatForever* action = new (std::nothrow) cocos2d::RepeatForever; action->initWithAction(cobj); jsb_ref_rebind(cx, jsobj, proxy, cobj, action, "cocos2d::RepeatForever"); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); return true; } @@ -2498,7 +2506,10 @@ bool js_cocos2dx_ActionInterval_speed(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ActionInterval_speed : Speed must not be negative"); return false; } - + + // no longer owned since it is going to be re-bound + cobj->_scriptOwned = false; + cocos2d::Speed* action = new (std::nothrow) cocos2d::Speed; action->initWithAction(cobj, speed); jsb_ref_rebind(cx, obj, proxy, cobj, action, "cocos2d::Speed"); @@ -2564,6 +2575,9 @@ bool js_cocos2dx_ActionInterval_easing(JSContext *cx, uint32_t argc, jsval *vp) double tag; double parameter; + // no longer owned since it will be re-bound + oldAction->_scriptOwned = false; + for (int i = 0; i < argc; i++) { // jsval vpi = argv[i]; diff --git a/cocos/scripting/js-bindings/script/jsb_prepare.js b/cocos/scripting/js-bindings/script/jsb_prepare.js index 6795d6c683..0f306f668b 100644 --- a/cocos/scripting/js-bindings/script/jsb_prepare.js +++ b/cocos/scripting/js-bindings/script/jsb_prepare.js @@ -278,6 +278,10 @@ cc.Class.extend = function (prop) { cc.log("No ctor function found! Please check whether `classes_need_extend` section in `ini` file like which in `tools/tojs/cocos2dx.ini`"); } else { + // "extended" object won't use the native finalize + // will will guarantee that the clean-up of the native + // object will called + this.__finalizeMe = new __jsc__.NativeFinalizeMe(this); this.ctor.apply(this, arguments); } } diff --git a/tests/js-memory-gc-tests/.cocos-project.json b/tests/js-memory-gc-tests/.cocos-project.json new file mode 100644 index 0000000000..b62bcef23e --- /dev/null +++ b/tests/js-memory-gc-tests/.cocos-project.json @@ -0,0 +1,58 @@ +{ + "project_type": "js", + "has_native": true, + "win32_cfg": { + "project_path": "../../build", + "sln_file": "cocos2d-win32.sln", + "project_name": "js-tests", + "build_cfg_path": "project/proj.win32", + "exe_out_dir": "js-tests" + }, + "ios_cfg": { + "project_path": "../../build", + "project_file": "cocos2d_tests.xcodeproj", + "target_name": "js-tests iOS" + }, + "mac_cfg": { + "project_path": "../../build", + "project_file": "cocos2d_tests.xcodeproj", + "target_name": "js-tests Mac" + }, + "android_cfg": { + "project_path": "project/proj.android", + "studio_proj_path" : "project/proj.android-studio" + }, + "web_cfg": { + "project_path": "", + "run_root_dir": "../../", + "sub_url": "/tests/js-tests/", + "copy_resources": [ + { + "from": "../cpp-tests/Resources/", + "to": "res/" + }, + { + "from": "resjs", + "to": "res/" + } + ] + }, + "linux_cfg": { + "project_path": "project/proj.linux", + "project_name": "js-tests", + "cmake_path": "../../", + "build_dir": "../../build/linux-build", + "build_result_dir": "js-tests" + }, + "wp8_1_cfg" : { + "project_path": "../../build", + "sln_file": "cocos2d-win8.1-universal.sln", + "project_name": "js-tests.WindowsPhone" + }, + "metro_cfg" : { + "project_path": "../../build", + "sln_file": "cocos2d-win8.1-universal.sln", + "project_name": "js-tests.Windows" + }, + "engine_dir": "../../" +} diff --git a/tests/js-memory-gc-tests/main.js b/tests/js-memory-gc-tests/main.js new file mode 100644 index 0000000000..625d5f58ed --- /dev/null +++ b/tests/js-memory-gc-tests/main.js @@ -0,0 +1,130 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011 Zynga Inc. + + http://www.cocos2d-x.org + + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** + * A brief explanation for "project.json": + * Here is the content of project.json file, this is the global configuration for your game, you can modify it to customize some behavior. + * The detail of each field is under it. + { + "debugMode" : 1, + // "debugMode" possible values : + // 0 - No message will be printed. + // 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. + // 2 - cc.error, cc.assert, cc.warn will print in console. + // 3 - cc.error, cc.assert will print in console. + // 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web. + // 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. + // 6 - cc.error, cc.assert will print on canvas, available only on web. + + "showFPS" : true, + // Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide. + + "frameRate" : 60, + // "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. + + "noCache" : false, + // "noCache" set whether your resources will be loaded with a timestamp suffix in the url. + // In this way, your resources will be force updated even if the browser holds a cache of it. + // It's very useful for mobile browser debuging. + + "id" : "gameCanvas", + // "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web. + + "renderMode" : 0, + // "renderMode" sets the renderer type, only useful on web : + // 0 - Automatically chosen by engine + // 1 - Forced to use canvas renderer + // 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers + + "engineDir" : "../../frameworks/cocos2d-html5/", + // In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir", + // but if you are using a single engine file, you can ignore it. + + "modules" : ["cocos2d", "extensions", "external"], + // "modules" defines which modules you will need in your game, it's useful only on web, + // using this can greatly reduce your game's resource size, and the cocos console tool can package your game with only the modules you set. + // For details about modules definitions, you can refer to "../../frameworks/cocos2d-html5/modulesConfig.json". + + "plugin": { + "facebook": { + "appId" : "1426774790893461", + "xfbml" : true, + "version" : "v2.0" + } + }, + // "plugin" is used by plugin-x for its settings, if you don't use it, you can ignore it. + + "jsList" : [ + ] + // "jsList" sets the list of js files in your game. + } + * + */ + +if(cc.sys){ + var scene3SearchPaths = cc.sys.localStorage.getItem("Scene3SearchPaths"); + if (scene3SearchPaths) + jsb.fileUtils.setSearchPaths(JSON.parse(scene3SearchPaths)); +} + +cc.game.onStart = function(){ + cc.view.enableRetina(false); + if (cc.sys.isNative) { + var resolutionPolicy = (cc.sys.os == cc.sys.OS_WP8 || cc.sys.os == cc.sys.OS_WINRT) ? cc.ResolutionPolicy.SHOW_ALL : cc.ResolutionPolicy.FIXED_HEIGHT; + cc.view.setDesignResolutionSize(800, 450, resolutionPolicy); + cc.view.resizeWithBrowserSize(true); + var searchPaths = jsb.fileUtils.getSearchPaths(); + searchPaths.push('script'); + searchPaths.push('src'); + var paths = [ + 'res' + ]; + for (var i = 0; i < paths.length; i++) { + searchPaths.push(paths[i]); + } + jsb.fileUtils.setSearchPaths(searchPaths); + } + else + { + cc.view.setDesignResolutionSize(800, 450, cc.ResolutionPolicy.SHOW_ALL); + cc.view.resizeWithBrowserSize(true); + // js-test use cpptest resource in debug mode , and in the release mode, console will copy the resource into the res dir + // so the respath will modify to res, + if (cc.game.config[cc.game.CONFIG_KEY.engineDir] !== "frameworks/cocos2d-html5") { + cc.loader.resPath = '../cpp-tests/Resources'; + } + else { + cc.loader.resPath = 'res'; + document.getElementById("cocosbanner").src = "res/Images/cocos2dbanner.png"; + } + } + + cc.LoaderScene.preload([], function () { + runMain(); + }, this); +}; +cc.game.run(); diff --git a/tests/js-memory-gc-tests/project.json b/tests/js-memory-gc-tests/project.json new file mode 100644 index 0000000000..8393725f40 --- /dev/null +++ b/tests/js-memory-gc-tests/project.json @@ -0,0 +1,23 @@ +{ + "debugMode" : 1, + "showFPS" : true, + "frameRate" : 60, + "noCache" : false, + "id" : "gameCanvas", + "renderMode" : 0, + "engineDir" : "../../web/", + + "modules" : ["cocos2d", "extensions", "external"], + + "plugin": { + "facebook": { + "appId" : "1426774790893461", + "xfbml" : true, + "version" : "v2.0" + } + }, + + "jsList" : [ + "src/tests-main.js" + ] +} diff --git a/tests/js-memory-gc-tests/project/CMakeLists.txt b/tests/js-memory-gc-tests/project/CMakeLists.txt new file mode 100644 index 0000000000..04afe8b7e9 --- /dev/null +++ b/tests/js-memory-gc-tests/project/CMakeLists.txt @@ -0,0 +1,87 @@ +#/**************************************************************************** +# Copyright (c) 2015 Chukong Technologies Inc. +# +# http://www.cocos2d-x.org +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# ****************************************************************************/ + +set(APP_NAME js-tests) + +if(WIN32) + +else() + set(PLATFORM_SRC + proj.linux/main.cpp + ) +endif() + +set(SAMPLE_SRC + Classes/AppDelegate.cpp + Classes/js_DrawNode3D_bindings.cpp + Classes/js_Effect3D_bindings.cpp + ${PLATFORM_SRC} +) + +include_directories( + Classes + ../../../cocos/scripting/js-bindings/auto + ../../../cocos/scripting/js-bindings/manual + ../../../cocos/base + ../../../cocos/editor-support + ../../../cocos/audio/include + ../../../external/spidermonkey/include/${PLATFORM_FOLDER} + ../../../external/chipmunk/include/chipmunk +) + +# add the executable +add_executable(${APP_NAME} + ${SAMPLE_SRC} +) + +target_link_libraries(${APP_NAME} + jscocos2d + cocos2d +) + +set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}") + +set_target_properties(${APP_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") + + +if(LINUX) + set(RES_PREFIX "/Resources") +else() + set(RES_PREFIX "") +endif() + +pre_build(${APP_NAME} + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}${RES_PREFIX}/script + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}${RES_PREFIX}/res + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}${RES_PREFIX}/src + COMMAND ${CMAKE_COMMAND} -E remove ${APP_BIN_DIR}${RES_PREFIX}/*.js + COMMAND ${CMAKE_COMMAND} -E remove ${APP_BIN_DIR}${RES_PREFIX}/*.json + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../../cpp-tests/Resources ${APP_BIN_DIR}${RES_PREFIX}/res + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../res ${APP_BIN_DIR}${RES_PREFIX}/res + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}${RES_PREFIX}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../../../cocos/scripting/js-bindings/script ${APP_BIN_DIR}${RES_PREFIX}/script + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../main.js ${APP_BIN_DIR}${RES_PREFIX}/main.js + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../project.json ${APP_BIN_DIR}${RES_PREFIX}/project.json + ) diff --git a/tests/js-memory-gc-tests/project/Classes/AppDelegate.cpp b/tests/js-memory-gc-tests/project/Classes/AppDelegate.cpp new file mode 100644 index 0000000000..e35b31fc04 --- /dev/null +++ b/tests/js-memory-gc-tests/project/Classes/AppDelegate.cpp @@ -0,0 +1,185 @@ +#include "AppDelegate.h" + +#include "cocos2d.h" +#include "SimpleAudioEngine.h" +#include "ScriptingCore.h" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_builder_auto.hpp" +#include "jsb_cocos2dx_spine_auto.hpp" +#include "jsb_cocos2dx_3d_auto.hpp" +#include "jsb_cocos2dx_3d_extension_auto.hpp" +#include "jsb_cocos2dx_physics3d_auto.hpp" +#include "physics3d/jsb_cocos2dx_physics3d_manual.h" +#include "jsb_cocos2dx_navmesh_auto.hpp" +#include "navmesh/jsb_cocos2dx_navmesh_manual.h" +#include "3d/jsb_cocos2dx_3d_manual.h" +#include "extension/jsb_cocos2dx_extension_manual.h" +#include "cocostudio/jsb_cocos2dx_studio_manual.h" +#include "jsb_cocos2dx_studio_auto.hpp" +#include "jsb_cocos2dx_ui_auto.hpp" +#include "ui/jsb_cocos2dx_ui_manual.h" +#include "spine/jsb_cocos2dx_spine_manual.h" +#include "cocos2d_specifics.hpp" +#include "cocosbuilder/cocosbuilder_specifics.hpp" +#include "chipmunk/js_bindings_chipmunk_registration.h" +#include "localstorage/js_bindings_system_registration.h" +#include "jsb_opengl_registration.h" +#include "network/XMLHTTPRequest.h" +#include "network/jsb_websocket.h" +#include "network/jsb_socketio.h" +#include "cocosbuilder/js_bindings_ccbreader.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#include "platform/android/CCJavascriptJavaBridge.h" +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) +#include "platform/ios/JavaScriptObjCBridge.h" +#endif + +#include "js_Effect3D_bindings.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#include "jsb_cocos2dx_experimental_webView_auto.hpp" +#include "experimental/jsb_cocos2dx_experimental_webView_manual.h" +#endif + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#include "jsb_cocos2dx_experimental_video_auto.hpp" +#include "experimental/jsb_cocos2dx_experimental_video_manual.h" +#endif + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +#include "jsb_cocos2dx_audioengine_auto.hpp" +#endif + +USING_NS_CC; +USING_NS_CC_EXT; +using namespace CocosDenshion; + +AppDelegate::AppDelegate() +{ +} + +AppDelegate::~AppDelegate() +{ + ScriptEngineManager::destroyInstance(); +} + +void AppDelegate::initGLContextAttrs() +{ + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + + GLView::setGLContextAttrs(glContextAttrs); +} + +bool AppDelegate::applicationDidFinishLaunching() +{ + // initialize director + auto director = Director::getInstance(); + auto glview = director->getOpenGLView(); + if(!glview) { +#if(CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + glview = cocos2d::GLViewImpl::create("js-tests"); +#else + glview = cocos2d::GLViewImpl::createWithRect("js-tests", Rect(0,0,900,640)); +#endif + director->setOpenGLView(glview); + } + + // set FPS. the default value is 1.0/60 if you don't call this + director->setAnimationInterval(1.0 / 60); + + ScriptingCore* sc = ScriptingCore::getInstance(); + sc->addRegisterCallback(register_all_cocos2dx); + sc->addRegisterCallback(register_cocos2dx_js_core); + sc->addRegisterCallback(jsb_register_system); + + sc->addRegisterCallback(register_all_cocos2dx_extension); + sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + + sc->addRegisterCallback(jsb_register_chipmunk); + sc->addRegisterCallback(JSB_register_opengl); + + sc->addRegisterCallback(MinXmlHttpRequest::_js_register); + sc->addRegisterCallback(register_jsb_websocket); + sc->addRegisterCallback(register_jsb_socketio); + + sc->addRegisterCallback(register_all_cocos2dx_builder); + sc->addRegisterCallback(register_CCBuilderReader); + + sc->addRegisterCallback(register_all_cocos2dx_ui); + sc->addRegisterCallback(register_all_cocos2dx_ui_manual); + sc->addRegisterCallback(register_all_cocos2dx_studio); + sc->addRegisterCallback(register_all_cocos2dx_studio_manual); + + sc->addRegisterCallback(register_all_cocos2dx_spine); + sc->addRegisterCallback(register_all_cocos2dx_spine_manual); + + sc->addRegisterCallback(register_all_cocos2dx_3d); + sc->addRegisterCallback(register_all_cocos2dx_3d_manual); + + sc->addRegisterCallback(register_all_cocos2dx_3d_extension); + +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION + sc->addRegisterCallback(register_all_cocos2dx_physics3d); + sc->addRegisterCallback(register_all_cocos2dx_physics3d_manual); +#endif + +#if CC_USE_NAVMESH + sc->addRegisterCallback(register_all_cocos2dx_navmesh); + sc->addRegisterCallback(register_all_cocos2dx_navmesh_manual); +#endif + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + sc->addRegisterCallback(JavascriptJavaBridge::_js_register); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + sc->addRegisterCallback(JavaScriptObjCBridge::_js_register); +#endif + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + sc->addRegisterCallback(register_all_cocos2dx_experimental_webView); + sc->addRegisterCallback(register_all_cocos2dx_experimental_webView_manual); +#endif + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + sc->addRegisterCallback(register_all_cocos2dx_experimental_video); + sc->addRegisterCallback(register_all_cocos2dx_experimental_video_manual); +#endif + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + sc->addRegisterCallback(register_all_cocos2dx_audioengine); +#endif + + sc->start(); + sc->runScript("script/jsb_boot.js"); +#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) + sc->enableDebugger(); +#endif + + auto pEngine = ScriptingCore::getInstance(); + ScriptEngineManager::getInstance()->setScriptEngine(pEngine); + + ScriptingCore::getInstance()->runScript("main.js"); + + return true; +} + +// This function will be called when the app is inactive. When comes a phone call,it's be invoked too +void AppDelegate::applicationDidEnterBackground() +{ + auto director = Director::getInstance(); + director->stopAnimation(); + director->getEventDispatcher()->dispatchCustomEvent("game_on_hide"); + SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); + SimpleAudioEngine::getInstance()->pauseAllEffects(); +} + +// this function will be called when the app is active again +void AppDelegate::applicationWillEnterForeground() +{ + auto director = Director::getInstance(); + director->startAnimation(); + director->getEventDispatcher()->dispatchCustomEvent("game_on_show"); + SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); + SimpleAudioEngine::getInstance()->resumeAllEffects(); +} diff --git a/tests/js-memory-gc-tests/project/Classes/AppDelegate.h b/tests/js-memory-gc-tests/project/Classes/AppDelegate.h new file mode 100644 index 0000000000..aabb7fa2f4 --- /dev/null +++ b/tests/js-memory-gc-tests/project/Classes/AppDelegate.h @@ -0,0 +1,39 @@ +#ifndef _APP_DELEGATE_H_ +#define _APP_DELEGATE_H_ + +#include "platform/CCApplication.h" +/** + @brief The cocos2d Application. + + The reason for implement as private inheritance is to hide some interface call by Director. + */ +class AppDelegate : private cocos2d::Application +{ +public: + AppDelegate(); + virtual ~AppDelegate(); + + void initGLContextAttrs() override; + + /** + @brief Implement Director and Scene init code here. + @return true Initialize success, app continue. + @return false Initialize failed, app terminate. + */ + virtual bool applicationDidFinishLaunching() override; + + /** + @brief The function be called when the application enter background + @param the pointer of the application + */ + virtual void applicationDidEnterBackground() override; + + /** + @brief The function be called when the application enter foreground + @param the pointer of the application + */ + virtual void applicationWillEnterForeground() override; +}; + +#endif // _APP_DELEGATE_H_ + diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/.gitignore b/tests/js-memory-gc-tests/project/proj.android-studio/.gitignore new file mode 100644 index 0000000000..9c4de5825b --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/.gitignore @@ -0,0 +1,7 @@ +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/.gitignore b/tests/js-memory-gc-tests/project/proj.android-studio/app/.gitignore new file mode 100644 index 0000000000..1de99493d6 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/app/.gitignore @@ -0,0 +1,2 @@ +/build +/jniLibs diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/AndroidManifest.xml b/tests/js-memory-gc-tests/project/proj.android-studio/app/AndroidManifest.xml new file mode 100644 index 0000000000..e7922a2b1e --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/app/AndroidManifest.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/build.gradle b/tests/js-memory-gc-tests/project/proj.android-studio/app/build.gradle new file mode 100644 index 0000000000..e840b5a973 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/app/build.gradle @@ -0,0 +1,50 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId "org.cocos2dx.js_tests" + minSdkVersion 10 + targetSdkVersion 22 + versionCode 1 + versionName "1.0" + + } + + sourceSets.main { + java.srcDir "src" + res.srcDir "res" + jniLibs.srcDir "libs" + manifest.srcFile "AndroidManifest.xml" + assets.srcDir "assets" + } + + signingConfigs { + + release { + if (project.hasProperty("RELEASE_STORE_FILE")) { + storeFile file(RELEASE_STORE_FILE) + storePassword RELEASE_STORE_PASSWORD + keyAlias RELEASE_KEY_ALIAS + keyPassword RELEASE_KEY_PASSWORD + } + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + if (project.hasProperty("RELEASE_STORE_FILE")) { + signingConfig signingConfigs.release + } + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile project(':libcocos2dx') +} diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/jni/Android.mk b/tests/js-memory-gc-tests/project/proj.android-studio/app/jni/Android.mk new file mode 100644 index 0000000000..dab475af1c --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/app/jni/Android.mk @@ -0,0 +1,23 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := js_tests_shared + +LOCAL_MODULE_FILENAME := libjs_tests + +LOCAL_SRC_FILES := main.cpp \ + ../../../Classes/AppDelegate.cpp \ + ../../../Classes/js_DrawNode3D_bindings.cpp \ + ../../../Classes/js_Effect3D_bindings.cpp + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes + +LOCAL_STATIC_LIBRARIES := cocos2d_js_static + + +LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=1 + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,scripting/js-bindings/proj.android) diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/jni/Application.mk b/tests/js-memory-gc-tests/project/proj.android-studio/app/jni/Application.mk new file mode 100644 index 0000000000..81ca21b08f --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/app/jni/Application.mk @@ -0,0 +1,17 @@ +APP_STL := gnustl_static + +# Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices +#APP_ABI := armeabi-v7a + +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic + +USE_ARM_MODE := 1 + +ifeq ($(NDK_DEBUG),1) + APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_OPTIM := debug +else + APP_CPPFLAGS += -DNDEBUG + APP_OPTIM := release +endif diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/jni/main.cpp b/tests/js-memory-gc-tests/project/proj.android-studio/app/jni/main.cpp new file mode 100644 index 0000000000..2d9745860d --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/app/jni/main.cpp @@ -0,0 +1,17 @@ +#include "AppDelegate.h" +#include "cocos2d.h" +#include "platform/android/jni/JniHelper.h" +#include +#include + +#define LOG_TAG "main" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) + +using namespace cocos2d; + +void cocos_android_app_init (JNIEnv* env) { + LOGD("cocos_android_app_init"); + AppDelegate *pAppDelegate = new AppDelegate(); + JavaVM* vm; + env->GetJavaVM(&vm); +} diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/proguard-rules.pro b/tests/js-memory-gc-tests/project/proj.android-studio/app/proguard-rules.pro new file mode 100644 index 0000000000..6618e28017 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-hdpi/ic_launcher.png b/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..45ee51d15f Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-hdpi/ic_launcher.png differ diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-mdpi/ic_launcher.png b/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..0dd2a60899 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-mdpi/ic_launcher.png differ diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-xhdpi/ic_launcher.png b/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..a32f16f930 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-xxhdpi/ic_launcher.png b/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..332f268edc Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.android-studio/app/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/res/values/strings.xml b/tests/js-memory-gc-tests/project/proj.android-studio/app/res/values/strings.xml new file mode 100644 index 0000000000..e0eefac763 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/app/res/values/strings.xml @@ -0,0 +1,3 @@ + + JSTests + diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/app/src/org/cocos2dx/js_tests/AppActivity.java b/tests/js-memory-gc-tests/project/proj.android-studio/app/src/org/cocos2dx/js_tests/AppActivity.java new file mode 100644 index 0000000000..72a437b604 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/app/src/org/cocos2dx/js_tests/AppActivity.java @@ -0,0 +1,80 @@ +/**************************************************************************** +Copyright (c) 2015 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +package org.cocos2dx.js_tests; + +import org.cocos2dx.js_tests.R; +import org.cocos2dx.lib.Cocos2dxActivity; +import org.cocos2dx.lib.Cocos2dxGLSurfaceView; +import org.cocos2dx.lib.Cocos2dxJavascriptJavaBridge; + +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.os.Bundle; + +public class AppActivity extends Cocos2dxActivity { + + private static AppActivity app = null; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + app = this; + } + + @Override + public Cocos2dxGLSurfaceView onCreateView() { + Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); + // TestCpp should create stencil buffer + glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); + + return glSurfaceView; + } + + public static void showAlertDialog(final String title, final String message) { + app.runOnUiThread(new Runnable() { + @Override + public void run() { + AlertDialog alertDialog = new AlertDialog.Builder(app).create(); + alertDialog.setTitle(title); + alertDialog.setMessage(message); + alertDialog.setCancelable(true); + alertDialog.setIcon(R.mipmap.ic_launcher); + alertDialog.setButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + app.runOnGLThread(new Runnable() { + @Override + public void run() { + + Cocos2dxJavascriptJavaBridge.evalString("cc.log(\"Javascript Java bridge!\")"); + } + }); + } + }); + alertDialog.show(); + } + }); + } + +} diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/build-cfg.json b/tests/js-memory-gc-tests/project/proj.android-studio/build-cfg.json new file mode 100644 index 0000000000..80c2622870 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/build-cfg.json @@ -0,0 +1,36 @@ +{ + "copy_resources": [ + { + "from": "../../src", + "to": "src" + }, + { + "from": "../../../cpp-tests/Resources/", + "to": "res/", + "exclude": [ + "*.gz" + ] + }, + { + "from": "../../main.js", + "to": "" + }, + { + "from": "../../project.json", + "to": "" + }, + { + "from": "../../../../cocos/scripting/js-bindings/script", + "to": "script" + }, + { + "from": "../../resjs", + "to": "res/resjs/" + } + ], + "ndk_module_path": [ + "../../../..", + "../../../../cocos", + "../../../../external" + ] +} diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/build.gradle b/tests/js-memory-gc-tests/project/proj.android-studio/build.gradle new file mode 100644 index 0000000000..1b7886d148 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/build.gradle @@ -0,0 +1,19 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.3.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/gradle.properties b/tests/js-memory-gc-tests/project/proj.android-studio/gradle.properties new file mode 100644 index 0000000000..1d3591c8a4 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true \ No newline at end of file diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/gradle/wrapper/gradle-wrapper.jar b/tests/js-memory-gc-tests/project/proj.android-studio/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..8c0fb64a86 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.android-studio/gradle/wrapper/gradle-wrapper.jar differ diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/gradle/wrapper/gradle-wrapper.properties b/tests/js-memory-gc-tests/project/proj.android-studio/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..1d87c27c59 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jul 31 20:40:49 CST 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/gradlew b/tests/js-memory-gc-tests/project/proj.android-studio/gradlew new file mode 100755 index 0000000000..91a7e269e1 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/gradlew.bat b/tests/js-memory-gc-tests/project/proj.android-studio/gradlew.bat new file mode 100644 index 0000000000..8a0b282aa6 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/tests/js-memory-gc-tests/project/proj.android-studio/settings.gradle b/tests/js-memory-gc-tests/project/proj.android-studio/settings.gradle new file mode 100644 index 0000000000..05e6a4191f --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android-studio/settings.gradle @@ -0,0 +1,4 @@ +include ':libcocos2dx' +project(':libcocos2dx').projectDir = new File(settingsDir, '../../../../cocos/platform/android/libcocos2dx') +include ':JSTests' +project(':JSTests').projectDir = new File(settingsDir, 'app') diff --git a/tests/js-memory-gc-tests/project/proj.android/.classpath b/tests/js-memory-gc-tests/project/proj.android/.classpath new file mode 100644 index 0000000000..3cd35c958e --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/js-memory-gc-tests/project/proj.android/.project b/tests/js-memory-gc-tests/project/proj.android/.project new file mode 100644 index 0000000000..0649734c25 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/.project @@ -0,0 +1,49 @@ + + + JSTests + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/tests/js-memory-gc-tests/project/proj.android/AndroidManifest.xml b/tests/js-memory-gc-tests/project/proj.android/AndroidManifest.xml new file mode 100644 index 0000000000..5fce9d7109 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/AndroidManifest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/js-memory-gc-tests/project/proj.android/ant.properties b/tests/js-memory-gc-tests/project/proj.android/ant.properties new file mode 100644 index 0000000000..f8af38bfb4 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/ant.properties @@ -0,0 +1 @@ +aapt.ignore.assets="!*.pvr.gz:!*.gz:!.svn:!.git:.*:_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~" diff --git a/tests/js-memory-gc-tests/project/proj.android/build-cfg.json b/tests/js-memory-gc-tests/project/proj.android/build-cfg.json new file mode 100644 index 0000000000..80c2622870 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/build-cfg.json @@ -0,0 +1,36 @@ +{ + "copy_resources": [ + { + "from": "../../src", + "to": "src" + }, + { + "from": "../../../cpp-tests/Resources/", + "to": "res/", + "exclude": [ + "*.gz" + ] + }, + { + "from": "../../main.js", + "to": "" + }, + { + "from": "../../project.json", + "to": "" + }, + { + "from": "../../../../cocos/scripting/js-bindings/script", + "to": "script" + }, + { + "from": "../../resjs", + "to": "res/resjs/" + } + ], + "ndk_module_path": [ + "../../../..", + "../../../../cocos", + "../../../../external" + ] +} diff --git a/tests/js-memory-gc-tests/project/proj.android/build.xml b/tests/js-memory-gc-tests/project/proj.android/build.xml new file mode 100644 index 0000000000..2f46f6e914 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/build.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/js-memory-gc-tests/project/proj.android/jni/Android.mk b/tests/js-memory-gc-tests/project/proj.android/jni/Android.mk new file mode 100644 index 0000000000..4ea163a5bb --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/jni/Android.mk @@ -0,0 +1,23 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := js_tests_shared + +LOCAL_MODULE_FILENAME := libjs_tests + +LOCAL_SRC_FILES := main.cpp \ + ../../Classes/AppDelegate.cpp \ + ../../Classes/js_DrawNode3D_bindings.cpp \ + ../../Classes/js_Effect3D_bindings.cpp + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes + +LOCAL_STATIC_LIBRARIES := cocos2d_js_static + + +LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=1 + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,scripting/js-bindings/proj.android) diff --git a/tests/js-memory-gc-tests/project/proj.android/jni/Application.mk b/tests/js-memory-gc-tests/project/proj.android/jni/Application.mk new file mode 100644 index 0000000000..81ca21b08f --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/jni/Application.mk @@ -0,0 +1,17 @@ +APP_STL := gnustl_static + +# Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices +#APP_ABI := armeabi-v7a + +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic + +USE_ARM_MODE := 1 + +ifeq ($(NDK_DEBUG),1) + APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_OPTIM := debug +else + APP_CPPFLAGS += -DNDEBUG + APP_OPTIM := release +endif diff --git a/tests/js-memory-gc-tests/project/proj.android/jni/main.cpp b/tests/js-memory-gc-tests/project/proj.android/jni/main.cpp new file mode 100644 index 0000000000..2d9745860d --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/jni/main.cpp @@ -0,0 +1,17 @@ +#include "AppDelegate.h" +#include "cocos2d.h" +#include "platform/android/jni/JniHelper.h" +#include +#include + +#define LOG_TAG "main" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) + +using namespace cocos2d; + +void cocos_android_app_init (JNIEnv* env) { + LOGD("cocos_android_app_init"); + AppDelegate *pAppDelegate = new AppDelegate(); + JavaVM* vm; + env->GetJavaVM(&vm); +} diff --git a/tests/js-memory-gc-tests/project/proj.android/ndkgdb.sh b/tests/js-memory-gc-tests/project/proj.android/ndkgdb.sh new file mode 100644 index 0000000000..b8b83e024f --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/ndkgdb.sh @@ -0,0 +1,47 @@ +APPNAME="JSTests" +APP_ANDROID_NAME="org.cocos2dx.js_tests" + +if [ -z "${SDK_ROOT+aaa}" ]; then +# ... if SDK_ROOT is not set, use "$HOME/bin/android-sdk" + SDK_ROOT="$HOME/bin/android-sdk" +fi + +if [ -z "${NDK_ROOT+aaa}" ]; then +# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk" + NDK_ROOT="$HOME/bin/android-ndk" +fi + +if [ -z "${COCOS2DX_ROOT+aaa}" ]; then +# ... if COCOS2DX_ROOT is not set +# ... find current working directory + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# ... use paths relative to current directory + COCOS2DX_ROOT="$DIR/../../.." + APP_ROOT="$DIR/.." + APP_ANDROID_ROOT="$DIR" +else + APP_ROOT="$COCOS2DX_ROOT/samples/$APPNAME" + APP_ANDROID_ROOT="$COCOS2DX_ROOT/samples/$APPNAME/proj.android" +fi + +echo "NDK_ROOT = $NDK_ROOT" +echo "SDK_ROOT = $SDK_ROOT" +echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" +echo "APP_ROOT = $APP_ROOT" +echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT" +echo "APP_ANDROID_NAME = $APP_ANDROID_NAME" + +echo +echo "Killing and restarting ${APP_ANDROID_NAME}" +echo + +set -x + +"${SDK_ROOT}"/platform-tools/adb shell am force-stop "${APP_ANDROID_NAME}" + +NDK_MODULE_PATH="${COCOS2DX_ROOT}":"${COCOS2DX_ROOT}"/cocos2dx/platform/third_party/android/prebuilt \ + "${NDK_ROOT}"/ndk-gdb \ + --adb="${SDK_ROOT}"/platform-tools/adb \ + --verbose \ + --start \ + --force diff --git a/tests/js-memory-gc-tests/project/proj.android/proguard-project.txt b/tests/js-memory-gc-tests/project/proj.android/proguard-project.txt new file mode 100644 index 0000000000..f2fe1559a2 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/tests/js-memory-gc-tests/project/proj.android/res/drawable-hdpi/icon.png b/tests/js-memory-gc-tests/project/proj.android/res/drawable-hdpi/icon.png new file mode 100644 index 0000000000..8aa4767c2f Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.android/res/drawable-hdpi/icon.png differ diff --git a/tests/js-memory-gc-tests/project/proj.android/res/drawable-ldpi/icon.png b/tests/js-memory-gc-tests/project/proj.android/res/drawable-ldpi/icon.png new file mode 100644 index 0000000000..17ce11a085 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.android/res/drawable-ldpi/icon.png differ diff --git a/tests/js-memory-gc-tests/project/proj.android/res/drawable-mdpi/icon.png b/tests/js-memory-gc-tests/project/proj.android/res/drawable-mdpi/icon.png new file mode 100644 index 0000000000..3780aac46c Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.android/res/drawable-mdpi/icon.png differ diff --git a/tests/js-memory-gc-tests/project/proj.android/res/values/strings.xml b/tests/js-memory-gc-tests/project/proj.android/res/values/strings.xml new file mode 100644 index 0000000000..4717131918 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/res/values/strings.xml @@ -0,0 +1,5 @@ + + + JSTests + 1426774790893461 + diff --git a/tests/js-memory-gc-tests/project/proj.android/src/org/cocos2dx/js_tests/AppActivity.java b/tests/js-memory-gc-tests/project/proj.android/src/org/cocos2dx/js_tests/AppActivity.java new file mode 100644 index 0000000000..6d97e1c13d --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.android/src/org/cocos2dx/js_tests/AppActivity.java @@ -0,0 +1,121 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +package org.cocos2dx.js_tests; + +import org.cocos2dx.js_tests.R; +import org.cocos2dx.lib.Cocos2dxActivity; +import org.cocos2dx.lib.Cocos2dxGLSurfaceView; +import org.cocos2dx.lib.Cocos2dxJavascriptJavaBridge; + +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.os.Bundle; + +public class AppActivity extends Cocos2dxActivity { + + private static AppActivity app = null; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + app = this; + } + + @Override + public Cocos2dxGLSurfaceView onCreateView() { + Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); + // TestCpp should create stencil buffer + glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); + + return glSurfaceView; + } + + public static void showAlertDialog(final String title, final String message) { + app.runOnUiThread(new Runnable() { + @Override + public void run() { + AlertDialog alertDialog = new AlertDialog.Builder(app).create(); + alertDialog.setTitle(title); + alertDialog.setMessage(message); + alertDialog.setCancelable(true); + alertDialog.setIcon(R.drawable.icon); + alertDialog.setButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + app.runOnGLThread(new Runnable() { + @Override + public void run() { + + Cocos2dxJavascriptJavaBridge.evalString("cc.log(\"Javascript Java bridge!\")"); + } + }); + } + }); + alertDialog.show(); + } + }); + } + public static void showAlertDialog(final String title, final String message, final boolean logicSwitch) { + app.runOnUiThread(new Runnable() { + @Override + public void run() { + AlertDialog alertDialog = new AlertDialog.Builder(app).create(); + alertDialog.setTitle(title); + alertDialog.setMessage(message); + alertDialog.setCancelable(true); + alertDialog.setIcon(R.drawable.icon); + String buttonStr = "it's false"; + if (logicSwitch) + { + buttonStr = "it's true"; + } + alertDialog.setButton(buttonStr, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + app.runOnGLThread(new Runnable() { + @Override + public void run() { + + Cocos2dxJavascriptJavaBridge.evalString("cc.log(\"Javascript Java bridge!\")"); + } + }); + } + }); + alertDialog.show(); + } + }); + } + + public static String getUtfStr() { + final String utf8Str = "you will see emotion:💝"; + app.runOnGLThread(new Runnable() { + @Override + public void run() { + + Cocos2dxJavascriptJavaBridge.evalString("cc.log(\"" + utf8Str + "\")"); + } + }); + return utf8Str; + } + +} diff --git a/tests/js-memory-gc-tests/project/proj.ios/AppController.h b/tests/js-memory-gc-tests/project/proj.ios/AppController.h new file mode 100644 index 0000000000..34545808e4 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.ios/AppController.h @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2010-2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +@class RootViewController; + +@interface AppController : NSObject +{ + UIWindow *window; + RootViewController *viewController; +} + +@end + diff --git a/tests/js-memory-gc-tests/project/proj.ios/AppController.mm b/tests/js-memory-gc-tests/project/proj.ios/AppController.mm new file mode 100644 index 0000000000..f146131894 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.ios/AppController.mm @@ -0,0 +1,144 @@ +/**************************************************************************** + Copyright (c) 2010-2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#import +#import "cocos2d.h" +#import "AppController.h" +#import "AppDelegate.h" +#import "RootViewController.h" +#import "platform/ios/CCEAGLView-ios.h" +//#import +@implementation AppController + +#pragma mark - +#pragma mark Application lifecycle + +// cocos2d application instance +static AppDelegate s_sharedApplication; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + + // Override point for customization after application launch. + + // Add the view controller's view to the window and display. + window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; + CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds] + pixelFormat: kEAGLColorFormatRGBA8 + depthFormat: GL_DEPTH24_STENCIL8_OES + preserveBackbuffer: NO + sharegroup: nil + multiSampling: NO + numberOfSamples: 0 ]; + + [eaglView setMultipleTouchEnabled:YES]; + + // Use RootViewController manage CCEAGLView + viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; + viewController.wantsFullScreenLayout = YES; + viewController.view = eaglView; + + // Set RootViewController to window + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this method on ios6 + [window setRootViewController:viewController]; + } + + [window makeKeyAndVisible]; + + [[UIApplication sharedApplication] setStatusBarHidden: YES]; + + // IMPORTANT: Setting the GLView should be done after creating the RootViewController + cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); + cocos2d::Director::getInstance()->setOpenGLView(glview); + + cocos2d::Application::getInstance()->run(); + return YES; +} +- (void)applicationWillResignActive:(UIApplication *)application { + /* + Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + */ + cocos2d::Director::getInstance()->pause(); +} +//- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation +//{ +// return [FBSession.activeSession handleOpenURL:url]; +//} +- (void)applicationDidBecomeActive:(UIApplication *)application { + /* + Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + */ +// [FBAppCall handleDidBecomeActive]; + cocos2d::Director::getInstance()->resume(); +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + /* + Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + If your application supports background execution, called instead of applicationWillTerminate: when the user quits. + */ + cocos2d::Application::getInstance()->applicationDidEnterBackground(); +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + /* + Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. + */ + cocos2d::Application::getInstance()->applicationWillEnterForeground(); +} + +- (void)applicationWillTerminate:(UIApplication *)application { + /* + Called when the application is about to terminate. + See also applicationDidEnterBackground:. + */ +} + + +#pragma mark - +#pragma mark Memory management + +- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { + /* + Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. + */ + cocos2d::Director::getInstance()->purgeCachedData(); +} + + +- (void)dealloc { + [super dealloc]; +} + +@end + diff --git a/tests/js-memory-gc-tests/project/proj.ios/Default-568h@2x.png b/tests/js-memory-gc-tests/project/proj.ios/Default-568h@2x.png new file mode 100644 index 0000000000..66c6d1cead Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.ios/Default-568h@2x.png differ diff --git a/tests/js-memory-gc-tests/project/proj.ios/Default.png b/tests/js-memory-gc-tests/project/proj.ios/Default.png new file mode 100644 index 0000000000..dcb80725de Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.ios/Default.png differ diff --git a/tests/js-memory-gc-tests/project/proj.ios/Default@2x.png b/tests/js-memory-gc-tests/project/proj.ios/Default@2x.png new file mode 100644 index 0000000000..84689888a1 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.ios/Default@2x.png differ diff --git a/tests/js-memory-gc-tests/project/proj.ios/Icon-114.png b/tests/js-memory-gc-tests/project/proj.ios/Icon-114.png new file mode 100644 index 0000000000..c3807861ad Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.ios/Icon-114.png differ diff --git a/tests/js-memory-gc-tests/project/proj.ios/Icon-120.png b/tests/js-memory-gc-tests/project/proj.ios/Icon-120.png new file mode 100644 index 0000000000..a5b49ccbb1 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.ios/Icon-120.png differ diff --git a/tests/js-memory-gc-tests/project/proj.ios/Icon-144.png b/tests/js-memory-gc-tests/project/proj.ios/Icon-144.png new file mode 100644 index 0000000000..1526615c02 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.ios/Icon-144.png differ diff --git a/tests/js-memory-gc-tests/project/proj.ios/Icon-152.png b/tests/js-memory-gc-tests/project/proj.ios/Icon-152.png new file mode 100644 index 0000000000..8aa82506d0 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.ios/Icon-152.png differ diff --git a/tests/js-memory-gc-tests/project/proj.ios/Icon-57.png b/tests/js-memory-gc-tests/project/proj.ios/Icon-57.png new file mode 100644 index 0000000000..4fcc6fddff Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.ios/Icon-57.png differ diff --git a/tests/js-memory-gc-tests/project/proj.ios/Icon-72.png b/tests/js-memory-gc-tests/project/proj.ios/Icon-72.png new file mode 100644 index 0000000000..2c573c8df4 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.ios/Icon-72.png differ diff --git a/tests/js-memory-gc-tests/project/proj.ios/Icon-76.png b/tests/js-memory-gc-tests/project/proj.ios/Icon-76.png new file mode 100644 index 0000000000..8a1fa1850c Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.ios/Icon-76.png differ diff --git a/tests/js-memory-gc-tests/project/proj.ios/Info.plist b/tests/js-memory-gc-tests/project/proj.ios/Info.plist new file mode 100644 index 0000000000..2a4c9dabd3 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.ios/Info.plist @@ -0,0 +1,113 @@ + + + + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSExceptionDomains + + cocos2d-x.org + + NSIncludesSubdomains + + NSTemporaryExceptionAllowsInsecureHTTPLoads + + NSTemporaryExceptionMinimumTLSVersion + TLSv1.1 + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFiles + + Icon-72.png + Icon.png + Icon@2x.png + Icon-57.png + Icon-114.png + Icon-144.png + + CFBundleIcons + + CFBundlePrimaryIcon + + CFBundleIconFiles + + Icon-72.png + Icon.png + Icon@2x.png + Icon-57.png + Icon-114.png + Icon-144.png + + UIPrerenderedIcon + + + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleURLTypes + + + CFBundleURLSchemes + + fb1426774790893461 + + + + CFBundleVersion + 1.0 + FacebookAppID + 1426774790893461 + FacebookDisplayName + myFc + LSRequiresIPhoneOS + + UIAppFonts + + res/fonts/A Damn Mess.ttf + res/fonts/Abberancy.ttf + res/fonts/Abduction.ttf + res/fonts/American Typewriter.ttf + res/fonts/Courier New.ttf + res/fonts/Marker Felt.ttf + res/fonts/Paint Boy.ttf + res/fonts/Schwarzwald Regular.ttf + res/fonts/Scissor Cuts.ttf + res/fonts/tahoma.ttf + res/fonts/Thonburi.ttf + res/fonts/ThonburiBold.ttf + + UIPrerenderedIcon + + UIRequiredDeviceCapabilities + + accelerometer + + opengles-1 + + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationLandscapeLeft + + + diff --git a/tests/js-memory-gc-tests/project/proj.ios/NativeOcClass.h b/tests/js-memory-gc-tests/project/proj.ios/NativeOcClass.h new file mode 100644 index 0000000000..64e92cc0ab --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.ios/NativeOcClass.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013-2014 Chukong Technologies Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#import + +@interface NativeOcClass : NSObject + ++(float) callNative:(NSNumber *)a andInt:(NSString *)str; ++(void) callNativeWithParam:(NSString *)str; ++(NSString *)callNativeWithReturnString; ++(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content; ++(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content addBool:(BOOL)logicSwitch; ++(int)callNativeWithAdd:(NSNumber *)num1 and:(NSNumber *)num2; +@end diff --git a/tests/js-memory-gc-tests/project/proj.ios/NativeOcClass.m b/tests/js-memory-gc-tests/project/proj.ios/NativeOcClass.m new file mode 100644 index 0000000000..0bcfd9c355 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.ios/NativeOcClass.m @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2013-2014 Chukong Technologies Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#import "NativeOcClass.h" +#if TARGET_OS_IPHONE +#import +#elif TARGET_OS_MAC +#import +#endif +@implementation NativeOcClass ++(float) callNative:(NSNumber *)a andInt:(NSString *)str{ + float b = [a floatValue]+111.3333; + NSLog(@"callNative string is %@ and int value is %f",str,b); + return b; +} ++(void)callNativeWithParam:(NSString *)str{ + NSLog(@"callNativeWithParam: str is %@ ",str); +} ++(NSString *)callNativeWithReturnString{ + return @"yes is a return string form objective-c"; +} ++(BOOL)callNativeWithReturnBool{ + return true; +} ++(int)callNativeWithAdd:(NSNumber *)num1 and:(NSNumber *)num2{ + return [num1 intValue]+[num2 intValue]; +} +#if TARGET_OS_IPHONE ++(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content{ + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:content delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; + [alertView show]; + return true; +} ++(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content addBool:(BOOL)logicSwitch{ + if (logicSwitch) + { + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:content delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"it's true", nil]; + [alertView show]; + } + else + { + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:content delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"it's false", nil]; + [alertView show]; + } + return true; +} +#elif TARGET_OS_MAC + ++(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content{ + NSAlert *alert = [[NSAlert alloc] init]; + [alert addButtonWithTitle:@"OK"]; + [alert addButtonWithTitle:@"Cancel"]; + [alert setMessageText:title]; + [alert setInformativeText:content]; + [alert setAlertStyle:NSWarningAlertStyle]; + [alert runModal]; + return true; +} + ++(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content addBool:(BOOL)logicSwitch{ + NSAlert *alert = [[NSAlert alloc] init]; + if (logicSwitch) + { + [alert addButtonWithTitle:@"it's true"]; + [alert addButtonWithTitle:@"Cancel"]; + } + else + { + [alert addButtonWithTitle:@"it's false"]; + [alert addButtonWithTitle:@"Cancel"]; + } + + [alert setMessageText:title]; + [alert setInformativeText:content]; + [alert setAlertStyle:NSWarningAlertStyle]; + [alert runModal]; + return true; +} +#endif +@end diff --git a/tests/js-memory-gc-tests/project/proj.ios/Prefix.pch b/tests/js-memory-gc-tests/project/proj.ios/Prefix.pch new file mode 100644 index 0000000000..b056d8694a --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.ios/Prefix.pch @@ -0,0 +1,8 @@ +// +// Prefix header for all source files of the 'testjs' target in the 'testjs' project +// + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/tests/js-memory-gc-tests/project/proj.ios/RootViewController.h b/tests/js-memory-gc-tests/project/proj.ios/RootViewController.h new file mode 100644 index 0000000000..11dfc4bf88 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.ios/RootViewController.h @@ -0,0 +1,33 @@ +/**************************************************************************** + Copyright (c) 2010-2011 cocos2d-x.org + Copyright (c) 2010 Ricardo Quesada + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#import + + +@interface RootViewController : UIViewController { + +} +- (BOOL)prefersStatusBarHidden; +@end diff --git a/tests/js-memory-gc-tests/project/proj.ios/RootViewController.mm b/tests/js-memory-gc-tests/project/proj.ios/RootViewController.mm new file mode 100644 index 0000000000..8438d7a420 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.ios/RootViewController.mm @@ -0,0 +1,79 @@ +// +// testjsAppController.h +// testjs +// +// Created by Rolando Abarca on 3/19/12. +// Copyright __MyCompanyName__ 2012. All rights reserved. +// + +#import "RootViewController.h" + + +@implementation RootViewController + +/* + // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { + // Custom initialization + } + return self; +} +*/ + +/* +// Implement loadView to create a view hierarchy programmatically, without using a nib. +- (void)loadView { +} +*/ + +/* +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad { + [super viewDidLoad]; +} + +*/ +// Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + return UIInterfaceOrientationIsLandscape( interfaceOrientation ); +} + +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ +#ifdef __IPHONE_6_0 + return UIInterfaceOrientationMaskAllButUpsideDown; +#endif +} + +- (BOOL) shouldAutorotate { + return YES; +} + +//fix not hide status on ios7 +- (BOOL)prefersStatusBarHidden +{ + return YES; +} + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + [super viewDidUnload]; + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/tests/js-memory-gc-tests/project/proj.ios/main.m b/tests/js-memory-gc-tests/project/proj.ios/main.m new file mode 100644 index 0000000000..e3dedca28b --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.ios/main.m @@ -0,0 +1,17 @@ +// +// main.m +// testjs +// +// Created by Rolando Abarca on 3/19/12. +// Copyright __MyCompanyName__ 2012. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) { + + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); + [pool release]; + return retVal; +} diff --git a/tests/js-memory-gc-tests/project/proj.linux/main.cpp b/tests/js-memory-gc-tests/project/proj.linux/main.cpp new file mode 100644 index 0000000000..e236a953b3 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.linux/main.cpp @@ -0,0 +1,10 @@ +#include "../Classes/AppDelegate.h" + +USING_NS_CC; + +int main(int argc, char **argv) +{ + // create the application instance + AppDelegate app; + return Application::getInstance()->run(); +} diff --git a/tests/js-memory-gc-tests/project/proj.mac/Icon.icns b/tests/js-memory-gc-tests/project/proj.mac/Icon.icns new file mode 100644 index 0000000000..3d09e8fb4f Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.mac/Icon.icns differ diff --git a/tests/js-memory-gc-tests/project/proj.mac/Test_Info.plist b/tests/js-memory-gc-tests/project/proj.mac/Test_Info.plist new file mode 100644 index 0000000000..608a82cdac --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.mac/Test_Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + Icon + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + ${MACOSX_DEPLOYMENT_TARGET} + NSHumanReadableCopyright + Copyright © 2012. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/tests/js-memory-gc-tests/project/proj.mac/Test_Prefix.pch b/tests/js-memory-gc-tests/project/proj.mac/Test_Prefix.pch new file mode 100644 index 0000000000..46c36a7e99 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.mac/Test_Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/tests/js-memory-gc-tests/project/proj.mac/en.lproj/InfoPlist.strings b/tests/js-memory-gc-tests/project/proj.mac/en.lproj/InfoPlist.strings new file mode 100644 index 0000000000..477b28ff8f --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.mac/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/tests/js-memory-gc-tests/project/proj.mac/en.lproj/MainMenu.xib b/tests/js-memory-gc-tests/project/proj.mac/en.lproj/MainMenu.xib new file mode 100644 index 0000000000..3dacdedbd0 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.mac/en.lproj/MainMenu.xib @@ -0,0 +1,812 @@ + + + + 1060 + 10K549 + 1938 + 1038.36 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 1938 + + + YES + NSMenuItem + NSCustomObject + NSMenu + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + YES + + NSApplication + + + FirstResponder + + + NSApplication + + + AMainMenu + + YES + + + TestCpp + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + TestCpp + + YES + + + About TestCpp + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + Services + + YES + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide TestCpp + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit TestCpp + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + View + + 1048576 + 2147483647 + + + submenuAction: + + View + + YES + + + Toggle Fullscreen + f + 1048576 + 2147483647 + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + Window + + YES + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + + Help + + 2147483647 + + + submenuAction: + + Help + + YES + + + TestCpp Help + ? + 1048576 + 2147483647 + + + + + _NSHelpMenu + + + + _NSMainMenu + + + AppController + + + NSFontManager + + + + + YES + + + terminate: + + + + 449 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + delegate + + + + 495 + + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + performZoom: + + + + 240 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + unhideAllApplications: + + + + 370 + + + + showHelp: + + + + 493 + + + + toggleFullScreen: + + + + 537 + + + + + YES + + 0 + + YES + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + YES + + + + + + + + + 19 + + + YES + + + + + + 56 + + + YES + + + + + + 57 + + + YES + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + + + 144 + + + + + 129 + + + + + 143 + + + + + 236 + + + + + 131 + + + YES + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + YES + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 295 + + + YES + + + + + + 296 + + + YES + + + + + + 420 + + + + + 490 + + + YES + + + + + + 491 + + + YES + + + + + + 492 + + + + + 494 + + + + + 536 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 129.IBPluginDependency + 130.IBPluginDependency + 131.IBPluginDependency + 134.IBPluginDependency + 136.IBPluginDependency + 143.IBPluginDependency + 144.IBPluginDependency + 145.IBPluginDependency + 149.IBPluginDependency + 150.IBPluginDependency + 19.IBPluginDependency + 23.IBPluginDependency + 236.IBPluginDependency + 239.IBPluginDependency + 24.IBPluginDependency + 29.IBPluginDependency + 295.IBPluginDependency + 296.IBPluginDependency + 420.IBPluginDependency + 490.IBPluginDependency + 491.IBPluginDependency + 492.IBPluginDependency + 494.IBPluginDependency + 5.IBPluginDependency + 536.IBPluginDependency + 56.IBPluginDependency + 57.IBPluginDependency + 58.IBPluginDependency + 92.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + + + + YES + + + + + 541 + + + + YES + + AppController + NSObject + + YES + + YES + exitFullScreen: + toggleFullScreen: + + + YES + id + id + + + + YES + + YES + exitFullScreen: + toggleFullScreen: + + + YES + + exitFullScreen: + id + + + toggleFullScreen: + id + + + + + YES + + YES + glView + window + + + YES + EAGLView + NSWindow + + + + YES + + YES + glView + window + + + YES + + glView + EAGLView + + + window + NSWindow + + + + + IBProjectSource + ./Classes/AppController.h + + + + EAGLView + NSOpenGLView + + IBProjectSource + ./Classes/EAGLView.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + + + YES + {9, 8} + {7, 2} + + + + diff --git a/tests/js-memory-gc-tests/project/proj.mac/main.cpp b/tests/js-memory-gc-tests/project/proj.mac/main.cpp new file mode 100644 index 0000000000..4b6a1e9021 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.mac/main.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2010 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "AppDelegate.h" +#include "cocos2d.h" + +USING_NS_CC; + +int main(int argc, char *argv[]) +{ + AppDelegate app; + return Application::getInstance()->run(); +} + diff --git a/tests/js-memory-gc-tests/project/proj.win32/build-cfg.json b/tests/js-memory-gc-tests/project/proj.win32/build-cfg.json new file mode 100644 index 0000000000..d1965344bc --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win32/build-cfg.json @@ -0,0 +1,24 @@ +{ + "copy_resources": [ + { + "from": "../../src", + "to": "src" + }, + { + "from": "../../../cpp-tests/Resources", + "to": "res" + }, + { + "from": "../../main.js", + "to": "" + }, + { + "from": "../../project.json", + "to": "" + }, + { + "from": "../../../../cocos/scripting/js-bindings/script", + "to": "script" + } + ] +} diff --git a/tests/js-memory-gc-tests/project/proj.win32/js-tests.rc b/tests/js-memory-gc-tests/project/proj.win32/js-tests.rc new file mode 100644 index 0000000000..3d664e8370 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win32/js-tests.rc @@ -0,0 +1,86 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\js-tests.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "js-tests Module\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "js-tests\0" + VALUE "LegalCopyright", "Copyright \0" + VALUE "OriginalFilename", "js-tests.exe\0" + VALUE "ProductName", "js-tests Module\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04B0 + END +END + +///////////////////////////////////////////////////////////////////////////// +#endif // !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) diff --git a/tests/js-memory-gc-tests/project/proj.win32/js-tests.vcxproj b/tests/js-memory-gc-tests/project/proj.win32/js-tests.vcxproj new file mode 100644 index 0000000000..7fb7e1ac10 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win32/js-tests.vcxproj @@ -0,0 +1,218 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {D0F06A44-A245-4D13-A498-0120C203B539} + js-tests + + + + Application + Unicode + v120 + v120_xp + v140 + v140_xp + + + Application + Unicode + v120 + v120_xp + v140 + v140_xp + + + + + + + + + + + + + + + + + <_ProjectFileVersion>12.0.21005.1 + $(SolutionDir)$(Configuration).win32\js-tests\ + $(Configuration).win32\ + false + $(SolutionDir)$(Configuration).win32\js-tests\ + $(Configuration).win32\ + false + AllRules.ruleset + + + AllRules.ruleset + + + + + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) + + + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) + + + + _DEBUG;%(PreprocessorDefinitions) + false + Win32 + true + $(IntDir)js-tests.tlb + js-tests.h + + + js-tests_i.c + js-tests_p.c + + + Disabled + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(ProjectDir)..\Classes;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + 4267;4251;4244;%(DisableSpecificWarnings) + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories) + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" + + + libcurl_imp.lib;mozjs-33.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + $(OutDir);$(SolutionDir)$(Configuration).win32;%(AdditionalLibraryDirectories) + true + Windows + MachineX86 + + + if not exist "$(OutDir)" mkdir "$(OutDir)" + +mkdir "$(OutDir)\script" +mkdir "$(OutDir)\src" +mkdir "$(OutDir)\res" +xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\js-bindings\script\*" "$(OutDir)\script" /e /Y +xcopy "$(ProjectDir)..\..\src" "$(OutDir)\src\" /e /Y +xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(OutDir)\res\" /e /Y +copy "$(ProjectDir)..\..\main.js" "$(OutDir)" +copy "$(ProjectDir)..\..\project.json" "$(OutDir)" +xcopy "$(ProjectDir)..\..\resjs" "$(OutDir)\res\resjs\" /e /Y + + + Copy js and resource files. + + + + + NDEBUG;%(PreprocessorDefinitions) + false + Win32 + true + $(IntDir)js-tests.tlb + js-tests.h + + + js-tests_i.c + js-tests_p.c + + + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(ProjectDir)..\Classes;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + MultiThreadedDLL + + + Level3 + + + 4267;4251;4244;%(DisableSpecificWarnings) + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories) + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" + + + libcurl_imp.lib;mozjs-33.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + $(OutDir);$(SolutionDir)$(Configuration).win32;%(AdditionalLibraryDirectories) + Windows + MachineX86 + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" + +mkdir "$(OutDir)\script" +mkdir "$(OutDir)\src" +mkdir "$(OutDir)\res" +xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\js-bindings\script\*" "$(OutDir)\script" /e /Y +xcopy "$(ProjectDir)..\..\src" "$(OutDir)\src\" /e /Y +xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(OutDir)\res\" /e /Y +copy "$(ProjectDir)..\..\main.js" "$(OutDir)" +copy "$(ProjectDir)..\..\project.json" "$(OutDir)" +xcopy "$(ProjectDir)..\..\resjs" "$(OutDir)\res\" /e /Y + Copy js and resource files. + + + + + + + + + + + + + + + + + + + + + + + + {39379840-825a-45a0-b363-c09ffef864bd} + + + + + + diff --git a/tests/js-memory-gc-tests/project/proj.win32/js-tests.vcxproj.filters b/tests/js-memory-gc-tests/project/proj.win32/js-tests.vcxproj.filters new file mode 100644 index 0000000000..b66e775a2e --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win32/js-tests.vcxproj.filters @@ -0,0 +1,55 @@ + + + + + Classes + + + win32 + + + Classes + + + Classes + + + + + Classes + + + win32 + + + win32 + + + Classes + + + Classes + + + + + {73cd069e-e032-4051-8d30-65b08ab4f954} + + + {abaf0468-14d3-43ce-8d1a-8a4a34dba59b} + + + {bbe7342c-1f30-4512-b00a-841aa2d4ca9f} + + + + + resource + + + + + resource + + + \ No newline at end of file diff --git a/tests/js-memory-gc-tests/project/proj.win32/main.cpp b/tests/js-memory-gc-tests/project/proj.win32/main.cpp new file mode 100644 index 0000000000..f5ce0656ed --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win32/main.cpp @@ -0,0 +1,34 @@ +#include "main.h" +#include "AppDelegate.h" + +USING_NS_CC; + +// uncomment below line, open debug console +// #define USE_WIN32_CONSOLE + +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + +#ifdef USE_WIN32_CONSOLE + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); +#endif + + // create the application instance + AppDelegate app; + + int ret = Application::getInstance()->run(); + +#ifdef USE_WIN32_CONSOLE + FreeConsole(); +#endif + + return ret; +} diff --git a/tests/js-memory-gc-tests/project/proj.win32/main.h b/tests/js-memory-gc-tests/project/proj.win32/main.h new file mode 100644 index 0000000000..e29aeedb3a --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win32/main.h @@ -0,0 +1,12 @@ +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Windows Header Files: +#include + +// C RunTime Header Files +#include "CCStdC.h" + +#endif // __WINMAIN_H__ diff --git a/tests/js-memory-gc-tests/project/proj.win32/res/js-tests.ico b/tests/js-memory-gc-tests/project/proj.win32/res/js-tests.ico new file mode 100644 index 0000000000..feaf932a74 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.win32/res/js-tests.ico differ diff --git a/tests/js-memory-gc-tests/project/proj.win32/resource.h b/tests/js-memory-gc-tests/project/proj.win32/resource.h new file mode 100644 index 0000000000..3436133bc7 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win32/resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by js-tests.RC +// + +#define IDS_PROJNAME 100 +#define IDR_TESTJS 100 + +#define ID_FILE_NEW_WINDOW 32771 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32775 +#endif +#endif diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/App.xaml b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/App.xaml new file mode 100644 index 0000000000..c0ea91604b --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/App.xaml @@ -0,0 +1,13 @@ + + + + + cpp_tests + + + diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/App.xaml.cpp b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/App.xaml.cpp new file mode 100644 index 0000000000..988ffe74de --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/App.xaml.cpp @@ -0,0 +1,143 @@ +#include "App.xaml.h" +#include "OpenGLESPage.xaml.h" + +using namespace Platform; +using namespace Windows::ApplicationModel; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Xaml::Media::Animation; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Interop; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; +using namespace cocos2d; +using namespace CocosAppWinRT; + +App::App() +{ + InitializeComponent(); + Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending); + Resuming += ref new EventHandler(this, &App::OnResuming); +} + +/// +/// Invoked when the application is launched normally by the end user. Other entry points +/// will be used when the application is launched to open a specific file, to display +/// search results, and so forth. +/// +/// Details about the launch request and process. +void App::OnLaunched(LaunchActivatedEventArgs^ e) +{ + auto rootFrame = dynamic_cast(Window::Current->Content); + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active. + if (rootFrame == nullptr) + { + // Create a Frame to act as the navigation context and associate it with + // a SuspensionManager key + rootFrame = ref new Frame(); + + // TODO: Change this value to a cache size that is appropriate for your application. + rootFrame->CacheSize = 1; + + if (e->PreviousExecutionState == ApplicationExecutionState::Terminated) + { + // TODO: Restore the saved session state only when appropriate, scheduling the + // final launch steps after the restore is complete. + } + + // Place the frame in the current Window + Window::Current->Content = rootFrame; + } + + if (rootFrame->Content == nullptr) + { +#if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP + // Removes the turnstile navigation for startup. + if (rootFrame->ContentTransitions != nullptr) + { + _transitions = ref new TransitionCollection(); + for (auto transition : rootFrame->ContentTransitions) + { + _transitions->Append(transition); + } + } + + rootFrame->ContentTransitions = nullptr; + _firstNavigatedToken = rootFrame->Navigated += ref new NavigatedEventHandler(this, &App::RootFrame_FirstNavigated); +#endif + + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter. + + rootFrame->Content = mPage = ref new OpenGLESPage(&mOpenGLES); + +#if 0 + if (!rootFrame->Navigate(OpenGLESPage::typeid, e->Arguments)) + { + throw ref new FailureException("Failed to create initial page"); + } +#endif + } + + // Ensure the current window is active + Window::Current->Activate(); +} + +#if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP +/// +/// Restores the content transitions after the app has launched. +/// +void App::RootFrame_FirstNavigated(Object^ sender, NavigationEventArgs^ e) +{ + auto rootFrame = safe_cast(sender); + + TransitionCollection^ newTransitions; + if (_transitions == nullptr) + { + newTransitions = ref new TransitionCollection(); + newTransitions->Append(ref new NavigationThemeTransition()); + } + else + { + newTransitions = _transitions; + } + + rootFrame->ContentTransitions = newTransitions; + + rootFrame->Navigated -= _firstNavigatedToken; +} +#endif + +/// +/// Invoked when application execution is being suspended. Application state is saved +/// without knowing whether the application will be terminated or resumed with the contents +/// of memory still intact. +/// +void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e) +{ + (void)sender; // Unused parameter + (void)e; // Unused parameter + + mPage->SetVisibility(false); +} + +/// +/// Invoked when application execution is being resumed. +/// +/// The source of the resume request. +/// Details about the resume request. +void App::OnResuming(Object ^sender, Object ^args) +{ + (void)sender; // Unused parameter + (void)args; // Unused parameter + + mPage->SetVisibility(true); +} diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/App.xaml.h b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/App.xaml.h new file mode 100644 index 0000000000..c177eab651 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/App.xaml.h @@ -0,0 +1,30 @@ +#pragma once + +#include "app.g.h" +#include "OpenGLES.h" +#include "openglespage.xaml.h" + +namespace CocosAppWinRT +{ + ref class App sealed + { + public: + App(); + virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override; + + private: + +#if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP + Windows::UI::Xaml::Media::Animation::TransitionCollection^ _transitions; + Windows::Foundation::EventRegistrationToken _firstNavigatedToken; + + void RootFrame_FirstNavigated(Platform::Object^ sender, Windows::UI::Xaml::Navigation::NavigationEventArgs^ e); +#endif + + void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); + void OnResuming(Platform::Object ^sender, Platform::Object ^args); + + OpenGLESPage^ mPage; + OpenGLES mOpenGLES; + }; +} diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems new file mode 100644 index 0000000000..4a353710a9 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems @@ -0,0 +1,64 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + e956c24b-f04e-47bf-bf00-746681ae1301 + {AE6763F6-1549-441E-AFB5-377BE1C776DC} + js-tests + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + Designer + + + + + $(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml + + + + + + $(MSBuildThisFileDirectory)App.xaml + + + + + $(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml + + + + + + $(MSBuildThisFileDirectory)App.xaml + + + Create + + + + + + + + <_CustomResource Include="$(MSBuildThisFileDirectory)..\..\Resources\**\*"> + Assets\Resources\%(RecursiveDir)%(FileName)%(Extension) + true + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems.filters b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems.filters new file mode 100644 index 0000000000..841a3ae6ee --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems.filters @@ -0,0 +1,46 @@ + + + + + + + + + Classes + + + Classes + + + Classes + + + + + + + + + + + {38ad799c-8c3c-44a2-8e41-516c8f62f556} + + + + + Classes + + + Classes + + + Classes + + + + + + + + + \ No newline at end of file diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/pch.cpp b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/pch.cpp new file mode 100644 index 0000000000..bcb5590be1 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/pch.cpp @@ -0,0 +1 @@ +#include "pch.h" diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/pch.h b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/pch.h new file mode 100644 index 0000000000..087ce3bf18 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Shared/pch.h @@ -0,0 +1,12 @@ +// +// pch.h +// Header for standard system include files. +// + +#pragma once + +#include "mozilla\Char16.h" +#include "cocos2d.h" +#include "cocos-ext.h" + + diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/Package.appxmanifest b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/Package.appxmanifest new file mode 100644 index 0000000000..e0dd7cb7a3 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/Package.appxmanifest @@ -0,0 +1,30 @@ + + + + + js-tests.Windows + msopentech + Assets\StoreLogo.png + + + 6.3.0 + 6.3.0 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj new file mode 100644 index 0000000000..2cbd6c135d --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj @@ -0,0 +1,338 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {70914FC8-7709-4CD6-B86B-C63FDE5478DB} + CocosAppWinRT + en-US + 12.0 + true + Windows Store + 8.1 + + + + Application + true + v120 + + + Application + true + v120 + + + Application + true + v120 + + + Application + false + false + v120 + + + Application + false + false + v120 + + + Application + false + false + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + js-tests.Windows_TemporaryKey.pfx + True + x86 + 2D1A6993BB7DD73FD4EDC183F0FA7F9A1B7AD3C3 + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;4101;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase + + + + + + + MSVCRT;%(IgnoreSpecificDefaultLibraries) + + + echo "Copying Windows 8.1 Universal App JavaScript template files" +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;4101;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase + + + + + + + echo "Copying Windows 8.1 Universal App JavaScript template files" +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;4101;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase + + + + + + + MSVCRT;%(IgnoreSpecificDefaultLibraries) + + + echo "Copying Windows 8.1 Universal App JavaScript template files" +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;4101;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase + + + + + + + echo "Copying Windows 8.1 Universal App JavaScript template files" +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;4101;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase + + + + + MSVCRT;%(IgnoreSpecificDefaultLibraries) + + + echo "Copying Windows 8.1 Universal App JavaScript template files" +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;4101;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase + + + echo "Copying Windows 8.1 Universal App CPP template files" +xcopy "$(EngineRoot)external\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)external\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)external\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq + + + + echo "Copying Windows 8.1 Universal App JavaScript template files" +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)tests\js-tests\project\proj.win8.1-universal\App.Shared\App.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\OpenGLES.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\Cocos2dRenderer.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\pch.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq +xcopy "$(EngineRoot)cocos\platform\win8.1-universal\cocos2d-js\pch.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /iycq + + + + + Designer + + + + + + + + + + + + {bcf5546d-66a0-4998-afd6-c5514f618930} + + + {9335005f-678e-4e8e-9b84-50037216aec8} + + + {f3550fe0-c795-44f6-8feb-093eb68143ae} + + + {3b26a12d-3a44-47ea-82d2-282660fc844d} + + + + + + \ No newline at end of file diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj.filters b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj.filters new file mode 100644 index 0000000000..0391f8dd5a --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj.filters @@ -0,0 +1,29 @@ + + + + + {1a9fa652-867e-41d2-8588-962f108d2d8f} + bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png + + + + + + + + + + + Assets + + + Assets + + + Assets + + + Assets + + + \ No newline at end of file diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows_TemporaryKey.pfx b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows_TemporaryKey.pfx new file mode 100644 index 0000000000..4d25179d42 Binary files /dev/null and b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows_TemporaryKey.pfx differ diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest new file mode 100644 index 0000000000..0568af1b21 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest @@ -0,0 +1,33 @@ + + + + + + js-tests.WindowsPhone + dalestam + Assets\StoreLogo.png + + + 6.3.1 + 6.3.1 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj new file mode 100644 index 0000000000..07385eb555 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj @@ -0,0 +1,165 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Release + ARM + + + Release + Win32 + + + + {94874B5B-398F-448A-A366-35A35DC1DB9C} + CocosAppWinRT + en-US + 12.0 + true + Windows Phone + 8.1 + + + + Application + true + v120_wp81 + + + Application + true + v120_wp81 + + + Application + false + false + v120_wp81 + + + Application + false + false + v120_wp81 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + arm + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;4101;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase + + + MSVCRT;%(IgnoreSpecificDefaultLibraries) + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;4101;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;4101;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + ProgramDatabase + + + MSVCRT;%(IgnoreSpecificDefaultLibraries) + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;4101;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + ProgramDatabase + + + + + Designer + + + + + + + + + + + + + {ca082ec4-17ce-430b-8207-d1e947a5d1e9} + + + {22f3b9df-1209-4574-8331-003966f562bf} + + + {cc1da216-a80d-4be4-b309-acb6af313aff} + + + {22f798d8-bfff-4754-996f-a5395343d5ec} + + + + + + \ No newline at end of file diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj.filters b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj.filters new file mode 100644 index 0000000000..eb71f325ca --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {c8beb60d-689b-4aaa-9749-99bd3e2dcf75} + bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + + + + \ No newline at end of file diff --git a/tests/js-memory-gc-tests/project/proj.win8.1-universal/resources.props b/tests/js-memory-gc-tests/project/proj.win8.1-universal/resources.props new file mode 100644 index 0000000000..bee92bbc47 --- /dev/null +++ b/tests/js-memory-gc-tests/project/proj.win8.1-universal/resources.props @@ -0,0 +1,69 @@ + + + + + + + $(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)external\spidermonkey\include\$(COCOS2D_PLATFORM);$(EngineRoot)cocos\base;%(AdditionalIncludeDirectories); + + + mozjs-33.lib;%(AdditionalDependencies) + $(EngineRoot)external\spidermonkey\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);%(AdditionalLibraryDirectories); + + + + + $(EngineRoot)external\spidermonkey\prebuilt\$(COCOS2D_PLATFORM)\$(Platform)\ + + + + + true + + + + + <_CustomResource Include="..\..\..\..\cpp-tests\Resources\**\*"> + Assets\Resources\res\%(RecursiveDir)%(FileName)%(Extension) + true + + + + <_CustomResource Include="..\..\..\src\**\*"> + Assets\Resources\src\%(RecursiveDir)%(FileName)%(Extension) + true + + + + <_CustomResource Include="..\..\..\..\..\cocos\scripting\js-bindings\script\**\*"> + Assets\Resources\script\%(RecursiveDir)%(FileName)%(Extension) + true + + + + <_CustomResource Include="..\..\..\main.js"> + Assets\Resources\%(RecursiveDir)%(FileName)%(Extension) + true + + + + <_CustomResource Include="..\..\..\project.json"> + Assets\Resources\%(RecursiveDir)%(FileName)%(Extension) + true + + + + <_CustomResource Include="..\..\..\resjs\**\*"> + Assets\Resources\res\resjs\%(RecursiveDir)%(FileName)%(Extension) + true + Always + + + + + + + + + + diff --git a/tests/js-memory-gc-tests/res/.gitignore b/tests/js-memory-gc-tests/res/.gitignore new file mode 100755 index 0000000000..1d65afe366 --- /dev/null +++ b/tests/js-memory-gc-tests/res/.gitignore @@ -0,0 +1,2 @@ +#Do now ignore Marmalade icf files +!*.icf diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_01.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_01.png new file mode 100755 index 0000000000..93aa6e983a Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_01.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_02.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_02.png new file mode 100755 index 0000000000..bf03d3312c Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_02.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_03.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_03.png new file mode 100755 index 0000000000..e01c593b40 Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_03.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_04.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_04.png new file mode 100755 index 0000000000..c9b0ae2529 Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_04.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_05.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_05.png new file mode 100755 index 0000000000..e65e6b2feb Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_05.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_06.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_06.png new file mode 100755 index 0000000000..4c3be2334f Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_06.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_07.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_07.png new file mode 100755 index 0000000000..4c38de3a78 Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_07.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_08.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_08.png new file mode 100755 index 0000000000..fad80b8e9a Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_08.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_09.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_09.png new file mode 100755 index 0000000000..b0fa9aded3 Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_09.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_10.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_10.png new file mode 100755 index 0000000000..0abb6eab93 Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_10.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_11.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_11.png new file mode 100755 index 0000000000..7285fd6c76 Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_11.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_12.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_12.png new file mode 100755 index 0000000000..ce7d672004 Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_12.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_13.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_13.png new file mode 100755 index 0000000000..92cbbd4da1 Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_13.png differ diff --git a/tests/js-memory-gc-tests/res/Images/grossini_dance_14.png b/tests/js-memory-gc-tests/res/Images/grossini_dance_14.png new file mode 100755 index 0000000000..ee7d1bba0a Binary files /dev/null and b/tests/js-memory-gc-tests/res/Images/grossini_dance_14.png differ diff --git a/tests/js-memory-gc-tests/src/tests-main.js b/tests/js-memory-gc-tests/src/tests-main.js new file mode 100644 index 0000000000..52cddc0fb1 --- /dev/null +++ b/tests/js-memory-gc-tests/src/tests-main.js @@ -0,0 +1,174 @@ +// Custom Sprite +var MySprite = cc.Sprite.extend({ + ctor: function (path) { + this._super(path); + }, + something: function (x, y) { + this.setPosition(x,y); + } +}); + +// +// Scene Test 1 +// +function runScene1(sender) { + + var scene = new cc.Scene(); + + for (i = 0; i < 5; i++) { + var sprite = new MySprite("res/Images/grossini_dance_01.png"); + sprite.something(50 + 50*i,200); + scene.addChild(sprite); + } + + // menu + var button = new cc.MenuItemFont("Go to Scene 2", runScene2); + button.fontSize = 20; + button.fontName = "Arial"; + var menu = new cc.Menu(); + menu.addChild(button); + menu.setPosition(300,20); + scene.addChild(menu); + + cc.director.replaceScene(scene); +} + +// +// Scene Test 2 +// +function runScene2(sender) { + + var scene = new cc.Scene(); + + for (i = 0; i < 5; i++) { + var sprite = new cc.Sprite("res/Images/grossini_dance_08.png"); + sprite.setPosition(50 + 50*i,200); + scene.addChild(sprite); + } + + // menu + var button = new cc.MenuItemFont("Go to Scene 3", runScene3); + button.fontSize = 20; + button.fontName = "Arial"; + var menu = new cc.Menu(); + menu.addChild(button); + menu.setPosition(300,20); + scene.addChild(menu); + + cc.director.replaceScene(scene); +} + +// +// Scene Test 3 +// +function runScene3(sender) { + + var scene = new cc.Scene(); + + var fontDef = new cc.FontDefinition(); + fontDef.fontName = "Arial"; + fontDef.fontSize = 32; + this.label = new cc.LabelTTF("See console!", fontDef); + this.label.setPosition(300,300); + scene.addChild(this.label); + + // menu + var button = new cc.MenuItemFont("Go to Scene 4", runScene4); + button.fontSize = 20; + button.fontName = "Arial"; + var menu = new cc.Menu(); + menu.addChild(button); + menu.setPosition(300,20); + scene.addChild(menu); + + // 'browser' can use touches or mouse. + // The benefit of using 'touches' in a browser, is that it works both with mouse events or touches events + if ('touches' in cc.sys.capabilities) { + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved: function (touches, event) { + var delta = touches[0].getDelta(); + cc.log("onTouchesMoved:" + delta); + return true; + } + }, + 10); + } else if ('mouse' in cc.sys.capabilities) { + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseMove: function (event) { + if(event.getButton() == cc.EventMouse.BUTTON_LEFT) + cc.log("onMouseMove" + event.getDelta()); + }, + onMouseScroll: function (event) { + var delta = cc.sys.isNative ? event.getScrollY() * 6 : -event.getScrollY(); + cc.log("onMouseScroll:" + delta); + return true; + } + }, + 10); + } + + cc.director.replaceScene(scene); +} + + +function runScene4(sender) { + + var scene = new cc.Scene(); + + var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4); + var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4); + var actionUp = cc.jumpBy(2, cc.p(0, 0), 80, 4); + var actionByBack = actionBy.reverse(); + + var delay = cc.delayTime(0.25); + + var sprite1 = new cc.Sprite("res/Images/grossini_dance_08.png"); + sprite1.setPosition(10,10); + var sprite2 = new cc.Sprite("res/Images/grossini_dance_01.png"); + sprite2.setPosition(200,10); + var sprite3 = new cc.Sprite("res/Images/grossini_dance_04.png"); + sprite3.setPosition(400,10); + + scene.addChild(sprite1); + scene.addChild(sprite2); + scene.addChild(sprite3); + + sprite1.runAction(actionTo); + sprite2.runAction(cc.sequence(actionBy, delay, actionByBack)); + + var action = cc.sequence(actionUp, delay.clone()).repeatForever(); + sprite3.runAction(action); + + + // menu + var button = new cc.MenuItemFont("Go to Scene 1", runScene1); + button.fontSize = 20; + button.fontName = "Arial"; + var menu = new cc.Menu(); + menu.addChild(button); + menu.setPosition(300,20); + scene.addChild(menu); + + cc.director.replaceScene(scene); +} + +// +// Main Entry point +// +function runMain() { + + var scene = new cc.Scene(); + + // menu + var button = new cc.MenuItemFont("Start Test", runScene1); + button.fontSize = 20; + button.fontName = "Arial"; + var menu = new cc.Menu(); + menu.addChild(button); + menu.setPosition(300,300); + + scene.addChild(menu); + cc.director.runScene(scene); +} diff --git a/tests/js-tests/main.js b/tests/js-tests/main.js index 6f55df4164..4c2749925c 100644 --- a/tests/js-tests/main.js +++ b/tests/js-tests/main.js @@ -27,7 +27,7 @@ /** * A brief explanation for "project.json": - * Here is the content of project.json file, this is the global configuration for your game, you can modify it to customize some behavior. + * Here is the content ofproject.json file, this is the global configuration for your game, you can modify it to customize some behavior. * The detail of each field is under it. { "debugMode" : 1,