Skip to content

Instantly share code, notes, and snippets.

@dpeek
Created May 27, 2012 03:58
Show Gist options
  • Save dpeek/2802113 to your computer and use it in GitHub Desktop.
Save dpeek/2802113 to your computer and use it in GitHub Desktop.
Haxe setter macro?
// haxe -x SetterTest
#if macro
import haxe.macro.Expr;
#end
class SetterTest
{
public static function main()
{
var foo = new SetterTest();
foo.bar = 1;
}
public function new(){}
public var bar(default, set_bar):Int;
@:macro function set_bar(ethis:Expr, evalue:Expr)
{
var pos = haxe.macro.Context.currentPos();
return {pos:pos, expr:EConst(CInt("10"))}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment