Skip to content

Instantly share code, notes, and snippets.

@RealyUniqueName
Created July 21, 2013 21:39
Show Gist options
  • Save RealyUniqueName/6050096 to your computer and use it in GitHub Desktop.
Save RealyUniqueName/6050096 to your computer and use it in GitHub Desktop.
Changing base class based on compilation flags
-main Main
-swf test.swf
#here we are selecting class to extend
-D custom_base=flash.display.Bitmap
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);
}
}
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