-
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert
lime.tools.Architecture
to enum abstract
.
This improves compatibility with `hxp.HostArchitecture` and provides a more user-friendly API than `try { Type.createEnum() }`.
- Loading branch information
Showing
3 changed files
with
69 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,63 @@ | ||
package lime.tools; | ||
|
||
enum Architecture | ||
import hxp.HostArchitecture; | ||
|
||
#if (haxe_ver >= 4.0) enum #else @:enum #end abstract Architecture(String) to String | ||
{ | ||
ARMV5; | ||
ARMV6; | ||
ARMV7; | ||
ARMV7S; | ||
ARM64; | ||
X86; | ||
X64; | ||
MIPS; | ||
MIPSEL; | ||
var ARMV5 = "ARMV5"; | ||
var ARMV6 = "ARMV6"; | ||
var ARMV7 = "ARMV7"; | ||
var ARMV7S = "ARMV7S"; | ||
var ARM64 = "ARM64"; | ||
var X86 = "X86"; | ||
var X64 = "X64"; | ||
var MIPS = "MIPS"; | ||
var MIPSEL = "MIPSEL"; | ||
|
||
public static function exists(architecture:String):Bool | ||
{ | ||
switch (architecture) | ||
{ | ||
case ARMV5, ARMV6, ARMV7, ARMV7S, ARM64, X86, X64, MIPS, MIPSEL: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
@:from private static function fromHostArchitecture(hostArchitecture:HostArchitecture):Architecture | ||
{ | ||
if (hostArchitecture == HostArchitecture.ARMV6) | ||
{ | ||
return ARMV6; | ||
} | ||
else if (hostArchitecture == HostArchitecture.ARMV7) | ||
{ | ||
return ARMV7; | ||
} | ||
else if (hostArchitecture == HostArchitecture.ARM64) | ||
{ | ||
return ARM64; | ||
} | ||
else if (hostArchitecture == HostArchitecture.X86) | ||
{ | ||
return X86; | ||
} | ||
else /* if (hostArchitecture == HostArchitecture.X64) */ | ||
{ | ||
return X64; | ||
} | ||
} | ||
|
||
@:from private static function fromString(string:String):Architecture | ||
{ | ||
if (exists(string)) | ||
{ | ||
return cast string; | ||
} | ||
else | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters