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
import haxe.macro.Expr; | |
using haxe.macro.Tools; | |
abstract Fast(Xml) from Xml to Xml { | |
@:noCompletion public inline function new(xml:Xml) this = xml; | |
public var name(get,never):String; | |
inline function get_name() return this.nodeName; | |
public var elements(get,never):FastIterator; |
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
import hxparse.Ruleset; | |
import hxparse.State; | |
import dot.Graph; | |
import dot.Node; | |
import dot.Attribute; | |
using Lambda; | |
class LexerGraph<T> { | |
var graph:Graph; |
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
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
import haxe.macro.Type; | |
using haxe.macro.Tools; | |
using Lambda; | |
class DeprecationMacro { | |
/** |
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 Main { | |
function new() { } | |
static function main() { | |
var intMap = [1 => "foo", 2 => "bar"]; | |
var stringMap = ["foo" => 1, "bar" => 2]; | |
var m1 = new Main(); | |
var m2 = new Main(); | |
var objMap = [m1 => "foo", m2 => "bar"]; |
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 Main { | |
var arg1:Int; | |
var arg2:String; | |
var arg3:Bool; | |
function new(arg1 = 0, arg2 = "foo", arg3 = false) { | |
MyMacro.initLocals(); | |
} | |
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
typedef Constructible = { | |
public function new():Void; | |
} | |
@:generic | |
class Gen<T:(Constructible, Main)> { | |
public function new() { } | |
public function make() { | |
return new T(); |
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 Main { | |
static public function main () { | |
var v = Printf.sprintf("The sum of $i and $i is $s.", 3, 5, "8"); | |
trace(v); // The sum of 3 and 5 is 8. | |
} | |
} |
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
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
import haxe.macro.Type; | |
class AbstractBuilder { | |
macro static public function build():Array<Field> { | |
var fields = Context.getBuildFields(); | |
var cCur = Context.getLocalClass().get(); | |
var fieldMap = [for (f in fields) f.name => true]; | |
function loop(c:ClassType) { |
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
interface I { | |
public function print(s:String):Void; | |
} | |
class C1 implements I { | |
public function new() { } | |
public function print(s) trace('C1: $s') | |
} | |
class C2 implements I { |
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
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
class Builder { | |
macro static function build():Array<Field> { | |
var funcExpr = macro function():String { | |
return "test"; | |
} | |
var ctorExpr = macro function(foo) { | |
trace("I was created with " +foo); |