2
0

MacroHelper.hx 755 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package h3d.impl;
  2. import haxe.macro.Context;
  3. import haxe.macro.Expr;
  4. class MacroHelper {
  5. #if macro
  6. static function replaceGLLoop( e : Expr ) {
  7. switch( e.expr ) {
  8. case EConst(CIdent("gl")):
  9. e.expr = EConst(CIdent("GL"));
  10. default:
  11. haxe.macro.ExprTools.iter(e, replaceGLLoop);
  12. }
  13. }
  14. public static function replaceGL() {
  15. var fields = Context.getBuildFields();
  16. for( f in fields )
  17. switch( f.kind ) {
  18. case FFun(f):
  19. if( f.expr != null ) replaceGLLoop(f.expr);
  20. default:
  21. }
  22. return fields;
  23. }
  24. #end
  25. public static macro function getResourcesPath() {
  26. var dir = haxe.macro.Context.definedValue("resourcesPath");
  27. if( dir == null ) dir = "res";
  28. return macro $v{try Context.resolvePath(dir) catch( e : Dynamic ) null};
  29. }
  30. }