Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package beluga.core.api;
- import haxe.macro.Expr.Field;
- import haxe.macro.Context;
- import haxe.macro.Expr;
- import beluga.core.MacroHelper;
- import haxe.macro.Compiler;
- /**
- * ...
- * @author Masadow
- */
- class APIBuilder
- {
- macro public static function build() : Array<Field>
- {
- var fields : Array<Field> = Context.getBuildFields();
- var pos = Context.currentPos();
- var modules : Array<String> = MacroHelper.getModules();
- for (module in modules)
- {
- var api : String = "beluga.module." + module.toLowerCase() + ".api." + module.charAt(0).toUpperCase() + module.substr(1) + "Api";
- fields.push({
- pos: pos,
- name: "do" + module.charAt(0).toUpperCase() + module.substr(1).toLowerCase(),
- meta: null,
- kind: FFun( {
- ret: null,
- params: [],
- expr: macro {
- d.dispatch(new $api(beluga, cast MacroHelper.getModuleInstanceByName($v{module})));
- },
- args: [ {
- value: null,
- type: macro : Dispatch,
- opt: false,
- name: "d"
- }]
- }),
- doc: null,
- access: [APublic]
- });
- }
- return fields;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement