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
package haxe.xml; | |
using StringTools; | |
enum State | |
{ | |
IGNORE_SPACES; | |
BEGIN; | |
BEGIN_NODE; | |
TAG_NAME; |
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; | |
class Main { | |
static function main() { | |
var a = generateCharCodeArray("foobar"); | |
trace(a); // [102,111,111,98,97,114] | |
} | |
#if haxe_211 | |
@:macro static public function generateCharCodeArray(source:String) { |
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 function main() { | |
trace(process(12)); // 24 | |
trace(process("Hello world")); // HELLO WORLD | |
} | |
@:generic static function process<T>(t:T):T { | |
return throw "unknown type: " + 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
@:font("C:/Windows/fonts/Arial.ttf", "a-zA-Z {}\\-\"1234") | |
class MyFont extends flash.text.Font { } | |
class Main { | |
static function main() { | |
var font = new MyFont(); | |
var fmt = new flash.text.TextFormat(); | |
fmt.size = 50; | |
fmt.font = font.fontName; |
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 function main() { | |
MyMacro.testReify(); | |
} | |
} |
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); |
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; | |
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
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
typedef Constructible = { | |
public function new():Void; | |
} | |
@:generic | |
class Gen<T:(Constructible, Main)> { | |
public function new() { } | |
public function make() { | |
return new T(); |
OlderNewer