Created
          July 21, 2013 21:39 
        
      - 
      
- 
        Save RealyUniqueName/6050096 to your computer and use it in GitHub Desktop. 
    Changing base class based on compilation flags
  
        
  
    
      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
    
  
  
    
  | -main Main | |
| -swf test.swf | |
| #here we are selecting class to extend | |
| -D custom_base=flash.display.Bitmap | 
  
    
      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.Context; | |
| import haxe.macro.Type; | |
| class Builder{ | |
| macro static public function getSpriteClass () : Type { | |
| var cls : String = ( | |
| Context.defined("custom_base") | |
| ? Context.definedValue("custom_base") | |
| : "flash.display.Sprite" //by default use this class | |
| ); | |
| return Context.getType(cls); | |
| } | |
| } | 
  
    
      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
    
  
  
    
  | class Main extends haxe.macro.MacroType<[Builder.getBaseClass()]> { | |
| //some code | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment