Created
November 8, 2013 20:43
-
-
Save fserb/7377327 to your computer and use it in GitHub Desktop.
Macro example
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 MyClass { | |
/* | |
usage: | |
function x() { | |
var c = new MyClass(); | |
var x = c.func(10); | |
} | |
*/ | |
macro public function func(ethis: Expr, block: Expr): Expr { | |
return a(ethis, block); | |
} | |
static function a(ethis: Expr, block: Expr): Expr { | |
return switch (block.expr) { | |
case EConst(c): | |
switch(c) { | |
case CInt(v): | |
macro function (t: Float): Bool { return t > $v{Std.parseInt(v)}; }; | |
default: | |
null; | |
} | |
default: null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment