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
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
@: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
/** | |
Хеширование строки | |
**/ | |
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
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
@: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
import haxe.macro.Expr; | |
import haxe.Constraints.Function; | |
#if macro | |
import haxe.macro.Context; | |
import haxe.macro.Type; | |
using haxe.macro.Tools; | |
#end | |
class DI { |
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 js.html.ArrayBuffer; | |
import js.html.DataView; | |
import DataTypes; | |
@:dce | |
@:build(DataMacro.build()) | |
abstract Data(DataView) { | |
var byte:Uint8; | |
var int:Int32; | |
var float:Float32; |
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; | |
import haxe.macro.Type; | |
using haxe.macro.Tools; | |
class LocaleMacro { | |
static function build():Array<Field> { | |
var fields = Context.getBuildFields(); | |
var newFields:Array<Field> = []; | |
for (field in fields) { |
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
@:build(MyMacro.build()) | |
abstract MapItem(Array<Dynamic>) { | |
var itemId:Int; | |
var defId:String; | |
} | |
class Main { | |
static function main() { | |
var item = new MapItem(); | |
item.itemId = 10; |