Skip to content

Instantly share code, notes, and snippets.

@fserb
Created November 8, 2013 20:43
Show Gist options
  • Save fserb/7377327 to your computer and use it in GitHub Desktop.
Save fserb/7377327 to your computer and use it in GitHub Desktop.
Macro example
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