Skip to content

Instantly share code, notes, and snippets.

@ibilon

ibilon/Test.hx Secret

Created June 1, 2018 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibilon/90d5b4f0c20f6bfcd380788ce680f6db to your computer and use it in GitHub Desktop.
Save ibilon/90d5b4f0c20f6bfcd380788ce680f6db to your computer and use it in GitHub Desktop.
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