override operators for WarnPriority

This commit is contained in:
Dima Granetchi
2017-02-02 17:44:45 +03:00
parent f4d1f1fc79
commit 31f1b9f405
+6 -1
View File
@@ -7,6 +7,11 @@ import haxe.macro.Expr.Position;
var ALL = 2; var ALL = 2;
var INFO = 1; var INFO = 1;
var LOW = 0; var LOW = 0;
@:op(a >= b) static function ge(a:WarnPriority, b:WarnPriority) return (a: Int) >= (b: Int);
@:op(a > b) static function g(a:WarnPriority, b:WarnPriority) return (a: Int) > (b: Int);
@:op(a < b) static function l(a:WarnPriority, b:WarnPriority) return (a: Int) < (b: Int);
@:op(a <= b) static function le(a:WarnPriority, b:WarnPriority) return (a: Int) <= (b: Int);
} }
class Warn { class Warn {
@@ -20,7 +25,7 @@ class Warn {
} }
public static function w(msg:String, pos:Position, level:WarnPriority) { public static function w(msg:String, pos:Position, level:WarnPriority) {
if ((Warn.level : Int) >= (level : Int)) if (Warn.level >= level)
Context.warning(msg, pos); Context.warning(msg, pos);
} }
} }