Last active
October 30, 2015 09:49
-
-
Save RealyUniqueName/042da33ec548d553a2bb to your computer and use it in GitHub Desktop.
Add getter & setter to openfl.events.Event
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
--macro addMetadata('@:build(EventBuilder.build())', 'openfl.events.Event'); |
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
package; | |
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
class EventBuilder | |
{ | |
/** | |
* Description | |
*/ | |
macro static public function build () : Array<Field> | |
{ | |
var fields = Context.getBuildFields().filter(function(field) return field.name != 'target'); | |
var definition = macro class Dummy { | |
public var target (get,set):Dynamic; | |
private var _target : Dynamic; | |
private function get_target () return _target; | |
private function set_target (t) return _target = t; | |
} | |
fields = fields.concat(definition.fields); | |
return fields; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment