Selaa lähdekoodia

added optional value argument to haxe.macro.Compiler.define

Simon Krajewski 12 vuotta sitten
vanhempi
commit
9017e31601
1 muutettua tiedostoa jossa 7 lisäystä ja 2 poistoa
  1. 7 2
      std/haxe/macro/Compiler.hx

+ 7 - 2
std/haxe/macro/Compiler.hx

@@ -26,14 +26,19 @@ import haxe.macro.Expr;
 	All these methods can be called for compiler configuration macros.
 	All these methods can be called for compiler configuration macros.
 **/
 **/
 class Compiler {
 class Compiler {
+	
+	macro static public function getDefine( key : String ) {
+		return macro $v{haxe.macro.Context.definedValue(key)};
+	}
 
 
 #if neko
 #if neko
 
 
 	static var ident = ~/^[A-Za-z_][A-Za-z0-9_]*$/;
 	static var ident = ~/^[A-Za-z_][A-Za-z0-9_]*$/;
 	static var path = ~/^[A-Za-z_][A-Za-z0-9_.]*$/;
 	static var path = ~/^[A-Za-z_][A-Za-z0-9_.]*$/;
 
 
-	public static function define( flag : String ) {
-		untyped load("define", 1)(flag.__s);
+	public static function define( flag : String, ?value : String ) untyped {
+		var v = flag + (value == null ? "" : "= " + value);
+		load("define", 1)(v.__s);
 	}
 	}
 
 
 	public static function removeField( className : String, field : String, ?isStatic : Bool ) {
 	public static function removeField( className : String, field : String, ?isStatic : Bool ) {