-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.hx
More file actions
90 lines (74 loc) · 2.12 KB
/
Config.hx
File metadata and controls
90 lines (74 loc) · 2.12 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
package insanity;
#if (!macro) import insanity.tools.Defines; #end
import insanity.backend.Expr;
import insanity.custom.*;
#if hl import insanity.custom.HL; #end
class Config { #if (!macro)
public static var interpClass:Class<insanity.backend.Interp> = insanity.backend.Interp;
public static var preprocessorValues:Map<String, Dynamic> = Defines.appendCompilerDefines([
'insanity' => '1'
]);
public static var globalVariables:Map<String, Dynamic> = [
'null' => null,
'true' => true,
'false' => false
];
public static var globalImports:Map<String, ImportMode> = [
'' => IAll
];
@:unreflective public static var typeProxy:Map<String, Dynamic> = [
#if hl
'Math' => HLMath,
#end
'Reflect' => InsanityReflect,
'Type' => InsanityType,
'Std' => InsanityStd
];
@:unreflective public static var blacklist:Map<ConfigBlacklistKind, Array<String>> = [
ByPackage(false) => [
],
ByPackage(true) => [
],
ByModule => [
],
ByType => [
],
];
#end }
class ConfigUtil {
public static function typeIsBlacklisted(type:Dynamic):Bool {
if (type == null) return false;
var name:String = (type is Enum ? Type.getEnumName(type) : Type.getClassName(type));
if (Config.blacklist.get(ByType)?.contains(name))
return true;
var info = insanity.backend.TypeCollection.main.fromCompilePath(name);
if (info != null) {
if (Config.blacklist.get(ByModule)?.contains(info[0].module))
return true;
if (Config.blacklist.get(ByPackage(false))?.contains(info[0].pack.join('.')))
return true;
if (Config.blacklist.exists(ByPackage(true))) {
var eq:Bool = false;
var pack:String = info[0].pack.join('.');
for (p in Config.blacklist.get(ByPackage(true))) {
if (StringTools.startsWith(pack, p))
return true;
}
}
}
return false;
}
public static function assertBlacklisted(type:Dynamic):Dynamic {
if (typeIsBlacklisted(type)) {
trace('WARNING: ${type is Enum ? Type.getEnumName(type) : Type.getClassName(type)} is blacklisted');
return null;
} else {
return type;
}
}
}
enum ConfigBlacklistKind {
ByPackage(recursive:Bool);
ByModule;
ByType;
}