Macros.hx 607 B

12345678910111213141516171819202122232425262728293031
  1. package hrt.texgraph;
  2. import haxe.macro.Context;
  3. import haxe.macro.Expr;
  4. import hxsl.Ast;
  5. using hxsl.Ast;
  6. using haxe.macro.Tools;
  7. class Macros {
  8. #if macro
  9. static function autoRegisterNode() {
  10. var fields = Context.getBuildFields();
  11. var thisClass = Context.getLocalClass();
  12. var cl = thisClass.get();
  13. var clPath = cl.pack.copy();
  14. clPath.push(cl.name);
  15. #if editor
  16. fields.push({
  17. name: "_",
  18. access: [Access.AStatic],
  19. kind: FieldType.FVar(macro:Bool, macro TexNode.register($v{cl.name}, ${clPath.toFieldExpr()})),
  20. pos: Context.currentPos(),
  21. });
  22. #end
  23. return fields;
  24. }
  25. #end
  26. }