From 5df798425565c25a9a03f125d4b2e16ab21dffc0 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Mon, 6 Apr 2015 12:37:08 -0700 Subject: [PATCH] Do not define -Dlime-legacy when using Lime hybrid --- .../extension-api/src/org/haxe/lime/Lime.java | 3 ++ haxe/Timer.hx | 4 +-- include.xml | 16 +++++++-- .../extension-api/src/org/haxe/lime/Lime.java | 4 +++ legacy/include.xml | 4 +-- legacy/project/Build.xml | 3 +- lime/project/HXProject.hx | 12 +++---- lime/tools/helpers/StringHelper.hx | 34 ++++++++++++------- 8 files changed, 55 insertions(+), 25 deletions(-) diff --git a/dependencies/extension-api/src/org/haxe/lime/Lime.java b/dependencies/extension-api/src/org/haxe/lime/Lime.java index d100957a2..448e9e3ff 100644 --- a/dependencies/extension-api/src/org/haxe/lime/Lime.java +++ b/dependencies/extension-api/src/org/haxe/lime/Lime.java @@ -7,6 +7,9 @@ public class Lime { static { System.loadLibrary("openal"); System.loadLibrary("lime"); + ::if DEFINE_LIME_HYBRID:: + System.loadLibrary("lime-legacy"); + ::end:: } public static final int ACTIVATE = 1; diff --git a/haxe/Timer.hx b/haxe/Timer.hx index bfed3733e..23c69cfb3 100644 --- a/haxe/Timer.hx +++ b/haxe/Timer.hx @@ -343,10 +343,10 @@ class Timer { } - #if lime_legacy + #if (lime_legacy || lime_hybrid) @:noCompletion public static function __nextWake (limit:Float):Float { - var now = lime_time_stamp () * 1000.0; + var now = getMS (); var sleep; for (timer in sRunningTimers) { diff --git a/include.xml b/include.xml index a6eca10c1..250b0e9b0 100644 --- a/include.xml +++ b/include.xml @@ -9,10 +9,22 @@ - + + + +
+ + + + + + +
+ + - + diff --git a/legacy/dependencies/extension-api/src/org/haxe/lime/Lime.java b/legacy/dependencies/extension-api/src/org/haxe/lime/Lime.java index 3342c349b..8ee86e4bf 100644 --- a/legacy/dependencies/extension-api/src/org/haxe/lime/Lime.java +++ b/legacy/dependencies/extension-api/src/org/haxe/lime/Lime.java @@ -5,6 +5,10 @@ package org.haxe.lime; public class Lime { static { + ::if DEFINE_LIME_HYBRID:: + System.loadLibrary("openal"); + System.loadLibrary("lime"); + ::end:: System.loadLibrary("lime-legacy"); } diff --git a/legacy/include.xml b/legacy/include.xml index 9e13f45eb..646f5755e 100644 --- a/legacy/include.xml +++ b/legacy/include.xml @@ -2,7 +2,7 @@
- + @@ -25,6 +25,6 @@
- +
diff --git a/legacy/project/Build.xml b/legacy/project/Build.xml index 9b91692d2..7638f6887 100644 --- a/legacy/project/Build.xml +++ b/legacy/project/Build.xml @@ -24,7 +24,7 @@ - + @@ -144,6 +144,7 @@ + diff --git a/lime/project/HXProject.hx b/lime/project/HXProject.hx index 06004bcc5..28c083910 100644 --- a/lime/project/HXProject.hx +++ b/lime/project/HXProject.hx @@ -882,7 +882,7 @@ class HXProject { if (StringTools.startsWith (haxeflag, "-lib")) { - Reflect.setField (context, "LIB_" + haxeflag.substr (5).toUpperCase (), "true"); + Reflect.setField (context, "LIB_" + StringHelper.formatUppercaseVariable (haxeflag.substr (5)), "true"); } @@ -1038,7 +1038,7 @@ class HXProject { #end - Reflect.setField (context, "LIB_" + haxelib.name.toUpperCase (), true); + Reflect.setField (context, "LIB_" + StringHelper.formatUppercaseVariable (haxelib.name), true); if (name == "nme") { @@ -1060,11 +1060,11 @@ class HXProject { if (value == null || value == "") { - Reflect.setField (context, "SET_" + key.toUpperCase (), true); + Reflect.setField (context, "SET_" + StringHelper.formatUppercaseVariable (key), true); } else { - Reflect.setField (context, "SET_" + key.toUpperCase (), value); + Reflect.setField (context, "SET_" + StringHelper.formatUppercaseVariable (key), value); } @@ -1078,13 +1078,13 @@ class HXProject { compilerFlags.push ("-D " + key); - Reflect.setField (context, "DEFINE_" + key.toUpperCase (), true); + Reflect.setField (context, "DEFINE_" + StringHelper.formatUppercaseVariable (key), true); } else { compilerFlags.push ("-D " + key + "=" + value); - Reflect.setField (context, "DEFINE_" + key.toUpperCase (), value); + Reflect.setField (context, "DEFINE_" + StringHelper.formatUppercaseVariable (key), value); } diff --git a/lime/tools/helpers/StringHelper.hx b/lime/tools/helpers/StringHelper.hx index d6188f283..0282ff98e 100644 --- a/lime/tools/helpers/StringHelper.hx +++ b/lime/tools/helpers/StringHelper.hx @@ -111,6 +111,7 @@ class StringHelper { public static function formatUppercaseVariable (name:String):String { + var isAlpha = ~/[A-Z0-9]/i; var variableName = ""; var lastWasUpperCase = false; @@ -118,13 +119,26 @@ class StringHelper { var char = name.charAt (i); - if (char == char.toUpperCase () && i > 0) { + if (!isAlpha.match (char)) { - if (lastWasUpperCase) { + variableName += "_"; + lastWasUpperCase = false; + + } else { + + if (char == char.toUpperCase () && i > 0) { - if (i == name.length - 1 || name.charAt (i + 1) == name.charAt (i + 1).toUpperCase ()) { + if (lastWasUpperCase) { - variableName += char; + if (i == name.length - 1 || name.charAt (i + 1) == name.charAt (i + 1).toUpperCase ()) { + + variableName += char; + + } else { + + variableName += "_" + char; + + } } else { @@ -132,19 +146,15 @@ class StringHelper { } + lastWasUpperCase = true; + } else { - variableName += "_" + char; + variableName += char.toUpperCase (); + lastWasUpperCase = false; } - lastWasUpperCase = true; - - } else { - - variableName += char.toUpperCase (); - lastWasUpperCase = false; - } }