Created
January 27, 2021 07:18
-
-
Save sonygod/58ef4c39ab8f99e8526d4eee5c1ad2be to your computer and use it in GitHub Desktop.
macro 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
| import haxe.macro.Expr; | |
| import haxe.macro.Context; | |
| @:remove @:autoBuild(GenIDIM.addID()) | |
| extern interface GenID {} | |
| class GenIDIM { | |
| public static function addID():Array<Field> { | |
| var fields:Array<Field> = Context.getBuildFields(); | |
| var idField:Field = { | |
| name: "_id", | |
| doc: null, | |
| meta: [], | |
| access: [AStatic, APrivate], | |
| kind: FVar(macro:Int, macro -1), | |
| pos: Context.currentPos() | |
| }; | |
| var getIdField:Field = { | |
| name: "getID", | |
| doc: "fuck", | |
| meta: [], | |
| access: [AStatic, APublic], | |
| kind: FFun({ | |
| params: [], | |
| args: [], | |
| expr: macro { | |
| if (_id == -1) { | |
| _id = 0; | |
| } | |
| return _id; | |
| }, | |
| ret: macro:Int | |
| }), | |
| pos: Context.currentPos() | |
| }; | |
| fields.push(idField); | |
| fields.push(getIdField); | |
| return fields; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
genMain
import haxe.macro.Context;
import haxe.macro.Expr;
@:remove @:autoBuild(GenMainBuild.buildFields())
extern interface GenMain {
}
class GenMainBuild {
macro public static function buildFields():Array {
var fields:Array = Context.getBuildFields();
var cls = Context.getLocalClass().get();
var pack = cls.pack.concat([cls.name]);
var name = pack.join(".");
}