deltaluca

Untitled

May 5th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.49 KB | None | 0 0
  1. @:autoBuild(ComponentID.run()) interface Component {}
  2.  
  3. class ComponentID {
  4.    public static function run() {
  5.       var fields = Context.getBuildFields();
  6.       // add static '_component_id' field to the objects static fields
  7.       return fields;
  8.    }
  9. }
  10.  
  11. class ComponentManager {
  12.    macro public static function getType(T:Expr) {
  13.       // convert T into expressing accessing _component_id
  14.       return macro _getType(T'sid);
  15.   }
  16.   static function _getType(id:Int):ComponentType { .. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment