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
@:remove | |
@:autoBuild(SkipSerializeMacro.build()) | |
interface ISkipSerialize {} |
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
class Main { | |
static function main() { | |
var event:MapChangeEvent<Map<String,Int>>; | |
$type(event.key); // String | |
$type(event.value); // Int | |
} | |
} |
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
/** | |
Хеширование строки | |
**/ | |
public static function hash(key:String):Int { | |
// простейший алгоритм djb2 | |
inline function cca(s:String, i:Int):Int { | |
// наиболее быстрое и небезопасное получение кода символа | |
#if js | |
return (untyped s).charCodeAt(i); |
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
import StructHelper.make; | |
typedef A = { | |
a:Int, | |
b:String, | |
c:Float, | |
d:Bool, | |
e:Array<Int>, | |
f:{ | |
g:Array<Bool>, |
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
@:dce | |
@:genericBuild(EitherMacro.build()) | |
class Either<Rest> {} |
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
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
class EnumComparisonMacro { | |
static function build() { | |
// get ComplexType for the abstract we're building | |
var t = switch(Context.getLocalType()) { | |
case TInst(_.get() => {kind: KAbstractImpl(_.get() => ab)}, _): TPath({pack: ab.pack, name: ab.name}); | |
case _: throw false; | |
} |
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
class Main { | |
static function main() { | |
var a = getValue(); | |
} | |
static function getValue():Tuple<Bool,Int> { | |
return new Tuple(true, 10); | |
} | |
} |
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
class Main { | |
static function main() { | |
var signal = new Signal<Int,String>(); | |
var conn = signal.connect(function(a, b) { | |
trace('Well done $a $b'); | |
}); | |
signal.dispatch(10, "lol"); | |
} | |
} |
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
import haxe.macro.Context; | |
import haxe.macro.Type; | |
using haxe.macro.Tools; | |
class CheckMutating { | |
static var metaToRemove:Array<MetaAccess>; | |
static function use() { | |
Context.onGenerate(function(types) { |
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
#if macro | |
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
using haxe.macro.Tools; | |
#end | |
@:enum abstract MyEnum<T>(T) {} | |
typedef A = MyEnum<Float>; | |
typedef B = Array<{a:Int, ?b:Array<{?a:String}>}>; | |
typedef C = Dynamic<Int>; |