forked from openfl/lime
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArchitecture.hx
More file actions
104 lines (93 loc) · 1.82 KB
/
Architecture.hx
File metadata and controls
104 lines (93 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package lime.tools;
import haxe.macro.Expr;
import hxp.HostArchitecture;
@:forward
enum abstract Architecture(String) to String
{
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;
}
}
/**
Returns the given `Architecture` if available, or `null` otherwise.
**/
public inline function new(name:String)
{
this = fromString(name.toUpperCase());
}
public inline function is64():Bool
{
return this == ARM64 || this == X64;
}
public inline function isARM():Bool
{
return this.indexOf("ARM") == 0;
}
public inline function isMIPS():Bool
{
return this == MIPS || this == MIPSEL;
}
public inline function isX():Bool
{
return this == X86 || this == X64;
}
@:noCompletion public macro function match(self:Expr, expr:Expr):Expr
{
return macro switch ($self)
{
case $expr:
true;
default:
false;
};
}
}