Skip to content

Instantly share code, notes, and snippets.

View waneck's full-sized avatar

Cauê Waneck waneck

  • São Paulo, Brazil
View GitHub Profile
@nadako
nadako / ArrayRead.hx
Last active March 14, 2024 07:57
Recursive read-only type generator for JSON structures (based on @:genericBuild)
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;
}
import haxe.macro.Expr;
class FTW
{
public static function build()
{
return haxe.macro.Context.getBuildFields().map(transformField);
}
static function transformField(field:Field)