diff --git a/CHANGELOG.md b/CHANGELOG.md index 10eccfbe9..3291954ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +2.6.7 (10/02/2015) +------------------ + +* Added initial changes to support Apple tvOS +* Added System.allowScreenTimeout to allow screensaver/sleep +* Updated CFFI to fix "hx_register_prim" issue on Android +* Improved "lime setup linux" +* Fixed preload when the same asset is listed twice +* Fixed an issue with importing lime.Assets in legacy builds + + 2.6.6 (09/24/2015) ------------------ diff --git a/haxelib.json b/haxelib.json index 71d8b8018..1a544977e 100644 --- a/haxelib.json +++ b/haxelib.json @@ -4,7 +4,7 @@ "license": "MIT", "tags": [], "description": "A flexible lightweight layer for Haxe cross-platform developers", - "version": "2.6.6", - "releasenote": "Patch for native static targets, minor fix", + "version": "2.6.7", + "releasenote": "Android CFFI fix, added System.allowScreenTimeout", "contributors": [ "singmajesty" ] } \ No newline at end of file diff --git a/lime/Assets.hx b/lime/Assets.hx index b5887b4ce..549f0caf4 100644 --- a/lime/Assets.hx +++ b/lime/Assets.hx @@ -1,4 +1,5 @@ -package lime; +package lime; #if (!lime_legacy || lime_hybrid) + #if !macro @@ -1497,6 +1498,7 @@ class Assets { } +#end #end diff --git a/lime/app/Preloader.hx b/lime/app/Preloader.hx index 2f2b6bc63..62aae4d93 100644 --- a/lime/app/Preloader.hx +++ b/lime/app/Preloader.hx @@ -82,24 +82,36 @@ class Preloader #if flash extends Sprite #end { case IMAGE: - var image = new Image (); - images.set (url, image); - image.onload = image_onLoad; - image.src = url; - total++; + if (!images.exists (url)) { + + var image = new Image (); + images.set (url, image); + image.onload = image_onLoad; + image.src = url; + total++; + + } case BINARY: - var loader = new URLLoader (); - loader.dataFormat = BINARY; - loaders.set (url, loader); - total++; + if (!loaders.exists (url)) { + + var loader = new URLLoader (); + loader.dataFormat = BINARY; + loaders.set (url, loader); + total++; + + } case TEXT: - var loader = new URLLoader (); - loaders.set (url, loader); - total++; + if (!loaders.exists (url)) { + + var loader = new URLLoader (); + loaders.set (url, loader); + total++; + + } case FONT: diff --git a/lime/net/URLLoader.hx b/lime/net/URLLoader.hx index b70378b22..b0d96c99c 100644 --- a/lime/net/URLLoader.hx +++ b/lime/net/URLLoader.hx @@ -365,7 +365,7 @@ class URLLoader { private function writeFunction (output:Bytes, size:Int, nmemb:Int):Int { - __data.readBytes (ByteArray.fromBytes (output)); + __data.writeBytes (ByteArray.fromBytes (output)); return size * nmemb; } diff --git a/lime/project/HXProject.hx b/lime/project/HXProject.hx index fe54b1afb..44c8f6d18 100644 --- a/lime/project/HXProject.hx +++ b/lime/project/HXProject.hx @@ -159,7 +159,9 @@ class HXProject { } } else if (target == Platform.TVOS) { + architectures = [ Architecture.ARM64 ]; + } else { architectures = [ Architecture.ARMV6 ]; diff --git a/lime/system/System.hx b/lime/system/System.hx index a29d8db81..c6b0712ba 100644 --- a/lime/system/System.hx +++ b/lime/system/System.hx @@ -33,6 +33,7 @@ import sys.io.Process; class System { + public static var allowScreenTimeout (get, set):Bool; public static var applicationDirectory (get, null):String; public static var applicationStorageDirectory (get, null):String; public static var desktopDirectory (get, null):String; @@ -227,6 +228,28 @@ class System { + private static function get_allowScreenTimeout ():Bool { + + #if ((cpp || neko || nodejs) && !macro) + return lime_system_get_allow_screen_timeout (); + #else + return true; + #end + + } + + + private static function set_allowScreenTimeout (value:Bool):Bool { + + #if ((cpp || neko || nodejs) && !macro) + return lime_system_set_allow_screen_timeout (value); + #else + return true; + #end + + } + + private static function get_applicationDirectory ():String { #if ((cpp || neko || nodejs) && !macro) @@ -394,6 +417,8 @@ class System { #if ((cpp || neko || nodejs) && !macro) + @:cffi private static function lime_system_get_allow_screen_timeout ():Bool; + @:cffi private static function lime_system_set_allow_screen_timeout (value:Bool):Bool; @:cffi private static function lime_system_get_directory (type:Int, company:String, title:String):Dynamic; @:cffi private static function lime_system_get_display (index:Int):Dynamic; @:cffi private static function lime_system_get_num_displays ():Int; diff --git a/lime/tools/platforms/MacPlatform.hx b/lime/tools/platforms/MacPlatform.hx index 171a94a6e..6efd5b212 100644 --- a/lime/tools/platforms/MacPlatform.hx +++ b/lime/tools/platforms/MacPlatform.hx @@ -238,12 +238,6 @@ class MacPlatform extends PlatformTarget { commands.push ([ "-Dmac", "-DHXCPP_M32" ]); } - - if (targetFlags.exists("tvos")) { - - commands.push ([ "-Dtvos", "-Dtoolchain=appletvos", "-DBINDIR=AppleTV" ]); - - } CPPHelper.rebuild (project, commands); diff --git a/project/include/hx/CFFIPrimePatch.h b/project/include/hx/CFFIPrimePatch.h index aca1e281c..cdd6f94bc 100644 --- a/project/include/hx/CFFIPrimePatch.h +++ b/project/include/hx/CFFIPrimePatch.h @@ -309,7 +309,7 @@ struct AutoValue #define DEFINE_PRIME12v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#else +#elif STATIC_LINK #define DEFINE_PRIME0(func) extern "C" { \ @@ -555,7 +555,202 @@ struct AutoValue int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ } + + +#else + + +#define DEFINE_PRIME0(func) extern "C" { \ + EXPORT value func##__prime(const char *inSig) { \ + if (!cffi::CheckSig0(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap() { return cffi::ToValue( func() ); } \ + EXPORT void *func##__0() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME0v(func) extern "C" { \ + EXPORT value func##__prime(const char *inSig) { \ + if (!cffi::CheckSig0(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap() { func(); return alloc_null(); } \ + EXPORT void *func##__0() { return (void*)(&func##__wrap); } \ +} + + +#define DEFINE_PRIME1(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig1(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(PRIME_ARG_DECL1) { return cffi::ToValue( func(PRIME_ARG_LIST1) ); } \ + EXPORT void *func##__1() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME1v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig1(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(PRIME_ARG_DECL1) { func(PRIME_ARG_LIST1); return alloc_null(); } \ + EXPORT void *func##__1() { return (void*)(&func##__wrap); } \ +} + + +#define DEFINE_PRIME2(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig2(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(PRIME_ARG_DECL2) { return cffi::ToValue( func(PRIME_ARG_LIST2) ); } \ + EXPORT void *func##__2() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME2v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig2(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(PRIME_ARG_DECL2) { func(PRIME_ARG_LIST2); return alloc_null(); } \ + EXPORT void *func##__2() { return (void*)(&func##__wrap); } \ +} + + +#define DEFINE_PRIME3(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig3(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(PRIME_ARG_DECL3) { return cffi::ToValue( func(PRIME_ARG_LIST3) ); } \ + EXPORT void *func##__3() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME3v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig3(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(PRIME_ARG_DECL3) { func(PRIME_ARG_LIST3); return alloc_null(); } \ + EXPORT void *func##__3() { return (void*)(&func##__wrap); } \ +} + + +#define DEFINE_PRIME4(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig4(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(PRIME_ARG_DECL4) { return cffi::ToValue( func(PRIME_ARG_LIST4) ); } \ + EXPORT void *func##__4() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME4v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig4(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(PRIME_ARG_DECL4) { func(PRIME_ARG_LIST4); return alloc_null(); } \ + EXPORT void *func##__4() { return (void*)(&func##__wrap); } \ +} + + +#define DEFINE_PRIME5(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig5(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(PRIME_ARG_DECL5) { return cffi::ToValue( func(PRIME_ARG_LIST5) ); } \ + EXPORT void *func##__5() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME5v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig5(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(PRIME_ARG_DECL5) { func(PRIME_ARG_LIST5); return alloc_null(); } \ + EXPORT void *func##__5() { return (void*)(&func##__wrap); } \ +} + + +#define DEFINE_PRIME6(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig6(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST6) ); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME6v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig6(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST6); return alloc_null(); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + + +#define DEFINE_PRIME7(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig7(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST7) ); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME7v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig7(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST7); return alloc_null(); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME8(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig8(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST8) ); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME8v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig8(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST8); return alloc_null(); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + + +#define DEFINE_PRIME9(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig9(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST9) ); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME9v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig9(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST9); return alloc_null(); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME10(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig10(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ +} + +#define DEFINE_PRIME10v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig10(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST10); return alloc_null(); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + + +#define DEFINE_PRIME11(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig11(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST11) ); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME11v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig11(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST11); return alloc_null(); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + + +#define DEFINE_PRIME12(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig12(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST12) ); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} + +#define DEFINE_PRIME12v(func) extern "C" { \ + EXPORT void *func##__prime(const char *inSig) { \ + if (!cffi::CheckSig12(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ + value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST12); return alloc_null(); } \ + EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ +} #endif #endif + diff --git a/project/include/system/System.h b/project/include/system/System.h index 5e9516cce..971e4109a 100644 --- a/project/include/system/System.h +++ b/project/include/system/System.h @@ -25,10 +25,12 @@ namespace lime { public: + static bool GetAllowScreenTimeout (); static const char* GetDirectory (SystemDirectory type, const char* company, const char* title); static value GetDisplay (int id); static int GetNumDisplays (); static double GetTimer (); + static bool SetAllowScreenTimeout (bool allow); }; diff --git a/project/lib/cairo b/project/lib/cairo index 2fd93965a..c60810bb1 160000 --- a/project/lib/cairo +++ b/project/lib/cairo @@ -1 +1 @@ -Subproject commit 2fd93965af0d7d55bc060a5b5108e4b1dfbb8a4e +Subproject commit c60810bb178c9e62e5956c200c3d9aef5bee6ef8 diff --git a/project/lib/openal b/project/lib/openal index af000b4b1..77986fa62 160000 --- a/project/lib/openal +++ b/project/lib/openal @@ -1 +1 @@ -Subproject commit af000b4b1f4485e63963c2aa1011ef7c5e3dd621 +Subproject commit 77986fa62e2218cf3d6a85198a0bbe6f1cfc0677 diff --git a/project/lib/pixman b/project/lib/pixman index d42fc0b90..e9f96d984 160000 --- a/project/lib/pixman +++ b/project/lib/pixman @@ -1 +1 @@ -Subproject commit d42fc0b903c7736b057a6daca7a22dc83db69aab +Subproject commit e9f96d98479b37985d400400b8e5187f6cb4ce6b diff --git a/project/lib/png b/project/lib/png index 601ea3ce9..31ee91f73 160000 --- a/project/lib/png +++ b/project/lib/png @@ -1 +1 @@ -Subproject commit 601ea3ce9b4af315bed7f371348305b28b3a231c +Subproject commit 31ee91f734c1d77149f0ad9fb9345780e6d00925 diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index df4d2362f..6b496bee8 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -1029,6 +1029,13 @@ namespace lime { } + bool lime_system_get_allow_screen_timeout () { + + return System::GetAllowScreenTimeout (); + + } + + value lime_system_get_directory (int type, HxString company, HxString title) { const char* path = System::GetDirectory ((SystemDirectory)type, company.__s, title.__s); @@ -1058,6 +1065,13 @@ namespace lime { } + bool lime_system_set_allow_screen_timeout (bool allow) { + + return System::SetAllowScreenTimeout (allow); + + } + + void lime_text_event_manager_register (value callback, value eventObject) { TextEvent::callback = new AutoGCRoot (callback); @@ -1359,10 +1373,12 @@ namespace lime { DEFINE_PRIME1v (lime_renderer_unlock); DEFINE_PRIME2v (lime_render_event_manager_register); DEFINE_PRIME2v (lime_sensor_event_manager_register); + DEFINE_PRIME0 (lime_system_get_allow_screen_timeout); DEFINE_PRIME3 (lime_system_get_directory); DEFINE_PRIME1 (lime_system_get_display); DEFINE_PRIME0 (lime_system_get_num_displays); DEFINE_PRIME0 (lime_system_get_timer); + DEFINE_PRIME1 (lime_system_set_allow_screen_timeout); DEFINE_PRIME2v (lime_text_event_manager_register); DEFINE_PRIME3 (lime_text_layout_create); DEFINE_PRIME5 (lime_text_layout_position); diff --git a/project/src/backend/sdl/SDLSystem.cpp b/project/src/backend/sdl/SDLSystem.cpp index ffbedafd1..d49732c57 100644 --- a/project/src/backend/sdl/SDLSystem.cpp +++ b/project/src/backend/sdl/SDLSystem.cpp @@ -80,6 +80,13 @@ namespace lime { } + bool System::GetAllowScreenTimeout () { + + return SDL_IsScreenSaverEnabled (); + + } + + const char* System::GetDirectory (SystemDirectory type, const char* company, const char* title) { switch (type) { @@ -312,6 +319,23 @@ namespace lime { } + bool System::SetAllowScreenTimeout (bool allow) { + + if (allow) { + + SDL_EnableScreenSaver (); + + } else { + + SDL_DisableScreenSaver (); + + } + + return allow; + + } + + FILE* FILE_HANDLE::getFile () { #ifndef HX_WINDOWS diff --git a/templates/haxe/DefaultAssetLibrary.hx b/templates/haxe/DefaultAssetLibrary.hx index a8fe0078b..b3e37c50b 100644 --- a/templates/haxe/DefaultAssetLibrary.hx +++ b/templates/haxe/DefaultAssetLibrary.hx @@ -315,15 +315,14 @@ class DefaultAssetLibrary extends AssetLibrary { #else if (className.exists (id)) { + var fontClass = className.get (id); return cast (Type.createInstance (fontClass, []), Image); } else { - #if tvos - return Image.fromFile ("assets/" + path.get (id)); - #else + return Image.fromFile (path.get (id)); - #end + } #end diff --git a/tools/CommandLineTools.hx b/tools/CommandLineTools.hx index 6d34e3815..76edabed3 100644 --- a/tools/CommandLineTools.hx +++ b/tools/CommandLineTools.hx @@ -240,12 +240,12 @@ class CommandLineTools { case "appletv", "appletvos": target = Platform.TVOS; - + case "appletvsim": target = Platform.TVOS; targetFlags.set ("simulator", ""); - + default: target = cast targetName.toLowerCase (); @@ -594,7 +594,7 @@ class CommandLineTools { case TVOS: platform = new TVOSPlatform (command, project, targetFlags); - + default: } @@ -759,7 +759,7 @@ class CommandLineTools { LogHelper.println (" \x1b[1mlinux\x1b[0m -- Create a Linux application"); LogHelper.println (" \x1b[1mmac\x1b[0m -- Create a Mac OS X application"); LogHelper.println (" \x1b[1mtizen\x1b[0m -- Create a Tizen application"); - LogHelper.println (" \x1b[1mtvos\x1b[0m -- Create an AppleTVOS application"); + LogHelper.println (" \x1b[1mtvos\x1b[0m -- Create a tvOS application"); LogHelper.println (" \x1b[1mwebos\x1b[0m -- Create a webOS application"); LogHelper.println (" \x1b[1mwindows\x1b[0m -- Create a Windows application"); LogHelper.println ("");