This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
import haxe.rtti.Meta; | |
@:tag('foo') typedef Foo = { | |
?bar:String, | |
?baz:Int | |
} | |
@:tag typedef Bar = Dynamic; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
import tink.macro.build.Member; | |
import tink.macro.build.MemberTransformer; | |
import haxe.macro.Type; | |
using tink.macro.tools.MacroTools; | |
using tink.core.types.Outcome; | |
class Optional { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
import tink.lang.Cls; | |
class Main { | |
static function main() { | |
var foods = 'cookie,soup,banana'.split(','); | |
var eaters = [new Human(), new CookieMonster(), new Robot()]; | |
for (e in eaters) | |
for (f in foods) | |
e.eat(f); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
class Main implements tink.lang.Cls { | |
static function main() | |
@with(tinx.node.Http.server(2000)) | |
@on(request) | |
request.respond().end('hello world') | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
@:build(MetaCheck.build()) | |
class Main { | |
static function main() { | |
trace(Meta.getStatics(Main).main.AngularSupport); | |
} | |
@AngularSupport({ inject:["$scope", '$http'], scope:'$scope' }) | |
function foo() {} | |
@AngularSupport({ inject:["$scope", '$http'], scfope:'$scope' })//will cause an error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
public var i(get, null):Int; | |
public function new() i = 0 | |
function get_i() return i-- | |
} | |
class Main { | |
static function main() | |
switch (new A()) { | |
case a if (a.i < 0): trace('negative'); | |
case a if (a.i == 0): trace('zero'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
abstract JsonMap<T>({ }) from {} { | |
public function new() this = {}; | |
public function exists(key:String) return Reflect.hasField(this, key); | |
@:arrayAccess public function get(key:String) return Reflect.field(this, key); | |
@:arrayAccess public function set(key:String, value:T):T { | |
Reflect.setField(this, key, value); | |
return value; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haxe.macro.Expr; | |
import haxe.macro.Context; | |
class Build { | |
static public function types() { | |
var pos = Context.currentPos(); | |
function mkPath(name:String):TypePath { | |
var parts = name.split('.'); | |
return { | |
sub: null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
import haxe.macro.Expr; | |
import haxe.macro.Context; | |
class Interp { | |
static function error(pos:Position, ?msg = 'Constant value expected'):Dynamic | |
return Context.error(msg, pos); | |
static function const(c:Constant, pos):Dynamic | |
return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
abstract Abstract<T>(T->Void) from (T->Void) { | |
function new(f:T->Void) | |
this = f; | |
} | |
class Example { | |
static function testAbstract(c:Abstract<haxe.ds.Option<Bool>>) { } | |
static function testFunction(c:haxe.ds.Option<Bool>->Void) { } |