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 DevTools { | |
| macro static public function measure(e, ?msg:String) { | |
| if (msg == null) | |
| msg = haxe.macro.ExprTools.toString(e); | |
| return macro @:pos(e.pos) { | |
| var start = haxe.Timer.stamp(), | |
| result = [$e];//wrapping in the array skews the result a bit, but avoids issues with Void | |
| var duration = haxe.Timer.stamp() - start; |
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 ; | |
| #if macro | |
| import haxe.macro.Expr; | |
| import haxe.macro.Context; | |
| using haxe.macro.ExprTools; | |
| #end | |
| class Foo { | |
| public function new() { |
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
| #if macro | |
| import haxe.macro.Expr; | |
| #else | |
| class Image { | |
| static public function img_tag(rr:RR, image: {path:String, w:Int, h:Int}, target_size):String { | |
| return '<img alt="whoops">'; | |
| } | |
| } | |
| #end | |
| typedef RR = 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.core.Future; | |
| using tink.core.Outcome; | |
| import haxe.Timer.*; | |
| class Main { | |
| macro static function benchmark(name:String, makeTrigger, getFuture, watch, trigger) | |
| return macro { | |
| name: $v{name}, |
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
| #if macro | |
| import haxe.macro.Context; | |
| import haxe.macro.Expr; | |
| #end | |
| abstract Signal<T>(Array<T>) | |
| { | |
| public inline function new() | |
| { | |
| this = []; |
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 ; | |
| using Main; | |
| typedef Future<T> = (T->Void)->Void; | |
| typedef Chain<T> = Future<Option<{ data: T, next: Chain<T>}>>; | |
| class Main { | |
| static function lazy<A>(g:Void->A) { | |
| var done = false, |
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.Type; | |
| import haxe.macro.Expr; | |
| import haxe.macro.Context; | |
| class Module { | |
| static function build(?module:String) { | |
| function isIncluded(meta:MetaAccess) |
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
| function wrapRouter(addRoute, basicFunctionality) { | |
| return { | |
| register: function (rule, handler) { | |
| require("util").inherits(handler, basicFunctionality); | |
| var factory = function (req, res) { | |
| this.request = req; | |
| this.response = res; | |
| }; | |
| factory.prototype = handler; | |
| addRoute(rule, function (req, res) { |
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 Map; | |
| import cpp.vm.Mutex; | |
| abstract ThreadSafeMap<K, V>({ data: IMap<K, V>, lock: Mutex }) { | |
| public function new(data:IMap<K, V>) | |
| this = { data: data, lock: new Mutex() } | |
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 { | |
| static function main() test(Foo); | |
| static function test(e:MyEnum) {} | |
| static function test2():MyEnum | |
| return Foo; | |
| } |