Skip to content

Instantly share code, notes, and snippets.

@Simn
Simn / Main.hx
Last active February 22, 2021 09:51
New reification examples
class Main {
static function main() {
MyMacro.testReify();
}
}
@Simn
Simn / Main.hx
Last active December 10, 2015 06:59
haxe @:font example
@: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;
@Simn
Simn / Main.hx
Created November 3, 2012 16:59
Function-based specialization wizardry in haxe3
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;
}
@Simn
Simn / Main.hx
Created October 16, 2012 10:52
Haxe macro for array of char codes
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) {
@Simn
Simn / XmlParser.hx
Created April 19, 2012 22:53
Port of neko C Xml parser to haxe
package haxe.xml;
using StringTools;
enum State
{
IGNORE_SPACES;
BEGIN;
BEGIN_NODE;
TAG_NAME;