Skip to content

Instantly share code, notes, and snippets.

View AxGord's full-sized avatar
🦄
Pony

Alexander Gordeyko AxGord

🦄
Pony
View GitHub Profile
@nadako
nadako / Const.hx
Created February 14, 2014 11:06
@:genericBuild read-only type builder
@:genericBuild(ConstMacro.build())
class Const<T> {}
@nadako
nadako / Main.hx
Created January 19, 2014 13:29
stack-allocated pair iterator
class Main
{
static function main()
{
var a = ["a", "b", "c"];
for (p in new IndexIter(a))
{
trace(p.idx);
trace(p.val);
@nadako
nadako / DynamicMap.hx
Last active January 2, 2016 22:29
Abstract wrapper for Dynamic objects.
/**
* Simple wrapper for anonymous structures that are meant to be used as a
* keyed collection of objects of the same type (i.e. json object).
*
* Wraps Reflect calls with nice syntax and static typing without any
* runtime overhead.
*/
abstract DynamicMap<V>(Dynamic<V>) from Dynamic<V>
{
/**
@RealyUniqueName
RealyUniqueName / Exception.hx
Created November 28, 2013 12:09
Simple exception class with stack information
package fst.exception;
import haxe.CallStack;
/**
* Exceptions base
*
*/
class Exception {
@Simn
Simn / Main.hx
Created August 2, 2013 08:32
Haxe generic type parameter construction
typedef Constructible = {
public function new():Void;
}
@:generic
class Gen<T:(Constructible, Main)> {
public function new() { }
public function make() {
return new T();
@Simn
Simn / AbstractBuilder.hx
Created February 22, 2013 07:48
Haxe abstract builder example
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) {