Siphon- a macro for collecting classes from packages

28 views
Skip to first unread message

Rezmason

unread,
Nov 28, 2012, 6:06:02 PM11/28/12
to haxe...@googlegroups.com
Hey guys,

I've written a macro called Siphon that inspects a package and returns a nice Hash<Class<Dynamic>>. Its main benefit is that it lets you control the composition of objects in your code with the folder structure and filename conventions you use to organize your source files. If that's your idea of fun, I hope you enjoy it. 

In this example, I use Siphon to compose a list of systems from the package that contains them. All of Siphon's parameters are optional.

var systems = new List<ISystem>();
var systemDefs = Siphon.getDefs("my.code.is.here.systems", "src",      "System"        ); 
//                              package,                   source dir, file name filter);  
for (def in systemDefs) systems.add(Type.createInstance(def, []));

Stephane Le Dorze

unread,
Nov 28, 2012, 7:19:39 PM11/28/12
to haxe...@googlegroups.com
why not making the filter a more general function instead? :)

Rezmason

unread,
Nov 28, 2012, 8:24:28 PM11/28/12
to haxe...@googlegroups.com
That would be neat, but I'm not sure how to make it happen– I think macro functions only accept literal values and expressions, and an expression of a function can't be used to call the function at compile time.

That said, the filter param is an EReg string, which should suffice for most use cases.
Reply all
Reply to author
Forward
0 new messages