Skip to content

Instantly share code, notes, and snippets.

@RealyUniqueName
Last active October 30, 2015 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RealyUniqueName/042da33ec548d553a2bb to your computer and use it in GitHub Desktop.
Save RealyUniqueName/042da33ec548d553a2bb to your computer and use it in GitHub Desktop.
Add getter & setter to openfl.events.Event
--macro addMetadata('@:build(EventBuilder.build())', 'openfl.events.Event');
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