Created
October 15, 2020 17:50
-
-
Save serjek/48042dd9503464c1fdc0d144eb87afc4 to your computer and use it in GitHub Desktop.
This file contains 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.*; | |
using haxe.macro.Tools; | |
using StringTools; | |
using Lambda; | |
class TestMinimal { | |
static function main() { | |
var m = new N(); //new M(); - this gives compilation error indicating that coconut magic was not applied | |
tracem(m.a); | |
} | |
public static macro function tracem(e:Array<Expr>) { | |
final desc = prettyString(e.map(v -> v.toString())); | |
var expr = macro { | |
trace($v{desc} +': '+ prettyString(($a{e}:Array<Dynamic>))); | |
null; | |
} | |
return macro $expr; | |
} | |
static function prettyString<T>(arr:Array<T>, ?sep:String = ', '):String | |
return arr.fold((a,b) -> b + (b == "" ? "" : sep) + a,""); | |
} | |
class M implements coconut.data.Model { | |
@:observable var a:String = "okay"; | |
} | |
class N { | |
public var a = "okay"; | |
public function new() {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment