-
-
Save ibilon/90d5b4f0c20f6bfcd380788ce680f6db to your computer and use it in GitHub Desktop.
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
class Test | |
{ | |
static function main () | |
{ | |
var t = Math.random(); | |
comment("This is a comment"); | |
trace(t); | |
} | |
static macro function comment (message:String) | |
{ | |
#if display | |
return macro null; | |
#end | |
var filename = "__tmp"; | |
var id = 0; | |
while (sys.FileSystem.exists('$filename$id')) | |
{ | |
++id; | |
} | |
var filename = '$filename$id'; | |
sys.io.File.saveContent(filename, "// " + message); | |
return macro { | |
haxe.macro.Compiler.includeFile($v{filename}, $v{haxe.macro.Compiler.IncludePosition.Inline}); | |
deleteFile($v{filename}); | |
}; | |
} | |
static macro function deleteFile (file:String) | |
{ | |
sys.FileSystem.deleteFile(file); | |
return macro null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment