Skip to content

Instantly share code, notes, and snippets.

(function($ctx) {
var $empty = function () { return function () {} };
var $estr = function () { return $ctx.Std.string(this) };
var $array = function (args, from, to) { return Array.prototype.slice.call(args, from, to); };
var $copy = function (from, to, overwrite) { for (var id in from) if (overwrite || (to[id] == null)) to[id] = from[id]; return to; };
var $c = function (s, c) { return { c: c, toString : function () { return s; }}};
var $init = [];
var $enum = function (path, constructs) {
this.__ename__ = path;
var c = this.__constructs__ = [];
@back2dos
back2dos / gist:1463037
Created December 11, 2011 22:05
Tink JS externals example
extern class Server {}
extern class ServerAPI implements TinkExt<Server> {
@:native listen(port:Int, ?hostname:String, ?handler:Server->Void);//when no type is defined, the target itself is returned
@:native(listen) listenToPath(path:String, ?handler:Server->Void);//both identifiers and strings are allowed to define native names
@:event request(request:ServerRequest, response:ServerResponse);
@:event(connection) socketInbound(socket:Socket);
}
//The above will now be expanded to:
extern class ServerAPI implements TinkExt<Server> {
@back2dos
back2dos / gist:1599299
Created January 12, 2012 07:52
Building functions
package ;
using tink.macro.tools.MacroTools;
import tink.macro.tools.AST;
import haxe.macro.Expr;
class Main {
static function main() {
var f = test1();
@back2dos
back2dos / gist:1664135
Created January 23, 2012 16:36
Tinkerbell chunk iteration
package ;
import haxe.FastList;
import haxe.Timer;
import tink.util.Benchmark;
import tink.util.ChunkIter;
import FL;
using tink.util.ChunkIter;
class IterTest {
@back2dos
back2dos / MacroLambda.hx
Created February 24, 2012 17:21 — forked from jdonaldson/MacroLambda.hx
MacroLambda: Automatically return new lists or arrays depending on the map argument type.
import haxe.macro.Expr;
import haxe.macro.Context;
class MacroLambda
{
public static function main(): Void
{
trace('Hello World');
@back2dos
back2dos / Main.hx
Created March 12, 2012 11:08
Fluent tag interface for haxe
package ;
using Tag;
class Main
{
static function main()
{
var t = "div".tag().att("id", "container")
.child("a".tag().att("href", "http://www.haxe.org")
@back2dos
back2dos / BindingsExample.hx
Created March 13, 2012 14:27
tink_reactive binding example
package ;
import flash.display.DisplayObjectContainer;
import flash.events.Event;
import flash.Lib;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
import haxe.PosInfos;
import haxe.Timer;
@back2dos
back2dos / Main.hx
Created June 17, 2012 18:08
combine @:forward with @:read/@:prop
package ;
import tink.lang.Cls;
class X implements Cls {
@:read var msg:String = _;
}
class Y implements Cls {
@:forward @:read var x:X = _;
}
class Main {
@back2dos
back2dos / Main.hx
Created July 20, 2012 09:59
Multiple level forward
package ;
import tink.lang.Cls;
class LevelSpec implements Cls {
@:read var x:Float = _;
}
class RunningLevel implements Cls {
@:forward var spec:LevelSpec = _;
}
@back2dos
back2dos / Main.hx
Created September 2, 2012 16:41
workaround
package;
import tink.lang.Cls;
class Foo<T> {
public var owner:T;
public function new() {
}
}
class Param {
}
class Main<T> implements Cls {