Skip to content

Instantly share code, notes, and snippets.

import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Printer;
import haxe.macro.Type;
using haxe.macro.Tools;
// The original code used interfaces to define properties, and some interfaces
// had the same property name with different types. These interfaces are then
// implemented by classes that provide the implementation of those properties.
@Simn
Simn / ArrayRead.hx
Last active September 6, 2019 10:54 — forked from nadako/ArrayRead.hx
abstract ArrayRead<T>(Array<T>) from Array<T> {
@:arrayAccess inline function get(i:Int):T return this[i];
public var length(get,never):Int;
inline function get_length() return this.length;
}
@Simn
Simn / Main.hx
Last active August 29, 2015 14:04
@:genericBuild DeclType
@:genericBuild(MyMacro.infer())
class DeclType<Const> { }
class Main {
static function main() {
var values = [for (i in 0...10) { i : i, hello: true }];
var list = [];
function example(v:DeclType<[values[0]]>) {
trace(v.i);
list.push(v);
@Simn
Simn / MyMacro.hx
Created March 21, 2016 15:56
Nicolas about Haxe #3
import haxe.macro.Context;
import haxe.macro.Expr;
class MyMacro {
public static function build( url : String ) {
var h = haxe.Http.requestUrl(url);
@Simn
Simn / Main.hx
Created March 22, 2016 20:52
Simple assert macro that shows sub-expressions
class Main {
static function main() {
var x = 7;
var y = 10;
tools.Assert.assert(x == 7 && y == 11);
}
}