diff --git a/extraParams.hxml b/extraParams.hxml index 36aa15c..72fd469 100644 --- a/extraParams.hxml +++ b/extraParams.hxml @@ -1 +1,2 @@ ---macro echoes.macro.ComponentStorageBuilder.invalidate() \ No newline at end of file +--macro echoes.macro.ComponentStorageBuilder.invalidate() +--macro echoes.macro.MacroTools.registerDescriptionFiles() diff --git a/meta.json b/meta.json new file mode 100644 index 0000000..f240554 --- /dev/null +++ b/meta.json @@ -0,0 +1,77 @@ +[ + { + "metadata": ":add", + "doc": "Makes a system function handle add events. The function will be called once an entity has the required components.", + "targets": ["TClassField"], + "links": ["./README.md#usage"] + }, + { + "metadata": ":echoes_add", + "doc": "Disambiguation alias for @:add.", + "targets": ["TClassField"], + "links": ["./README.md#usage"] + }, + { + "metadata": ":update", + "doc": "Makes a system function handle updates. Each update, it will be called for every entity that has the required components.", + "targets": ["TClassField"], + "links": ["./README.md#usage"] + }, + { + "metadata": ":echoes_update", + "doc": "Disambiguation alias for @:update.", + "targets": ["TClassField"], + "links": ["./README.md#usage"] + }, + { + "metadata": ":remove", + "doc": "Makes a system function handle remove events. The function will be called when an entity loses one of the required components, if it previously had all of them.", + "targets": ["TClassField"], + "links": ["./README.md#usage"] + }, + { + "metadata": ":echoes_remove", + "doc": "Disambiguation alias for @:remove.", + "targets": ["TClassField"], + "links": ["./README.md#usage"] + }, + { + "metadata": ":echoes_replace", + "doc": "Marks a type so that when added to an entity, if it already had a component of that type, a remove event will be dispatched first.", + "targets": ["TAbstract", "TClass", "TEnum", "TTypedef"] + }, + { + "metadata": ":priority", + "doc": "Sets the priority of a system or system function. Higher priorities happen first, and negative priorities are possible. The default priority is 0.", + "params": ["Integer"], + "targets": ["TClass", "TClassField"], + "links": ["./README.md#priority"] + }, + { + "metadata": ":echoes_priority", + "doc": "Disambiguation alias for @:priority.", + "params": ["Integer"], + "targets": ["TClass", "TClassField"], + "links": ["./README.md#priority"] + }, + { + "metadata": ":arguments", + "doc": "One or more component types to be taken as arguments in the entity template's constructor. Requires @:build(echoes.Entity.build()).", + "params": ["Type or type check"], + "targets": ["TAbstract"], + "links": ["./README.md#entity-templates", "./README.md#type-check-syntax"] + }, + { + "metadata": ":optionalArguments", + "doc": "One or more component types to be taken as optional arguments in the entity template's constructor. Requires @:build(echoes.Entity.build()).", + "params": ["Type or type check"], + "targets": ["TAbstract"], + "links": ["./README.md#entity-templates", "./README.md#type-check-syntax"] + }, + { + "metadata": ":echoes_storage", + "doc": "Sets the ComponentStorage instance used to store components of this type.", + "params": ["Constructor call or singleton instance"], + "targets": ["TAbstract", "TClass", "TEnum", "TTypedef"] + } +] diff --git a/src/echoes/macro/MacroTools.hx b/src/echoes/macro/MacroTools.hx index c0b2a52..3e825a3 100644 --- a/src/echoes/macro/MacroTools.hx +++ b/src/echoes/macro/MacroTools.hx @@ -3,6 +3,7 @@ package echoes.macro; #if macro import haxe.Exception; +import haxe.macro.Compiler; import haxe.macro.Expr; import haxe.macro.Printer; import haxe.macro.Type; @@ -213,6 +214,16 @@ class MacroTools { } } + public static function registerDescriptionFiles():Void { + var path:String = ((?infos:haxe.PosInfos) -> infos.fileName)(); + if(!StringTools.endsWith(path, "src/echoes/macro/MacroTools.hx")) { + throw "MacroTools.hx moved, please update its path."; + } + path = path.substring(0, path.length - "src/echoes/macro/MacroTools.hx".length); + + Compiler.registerMetadataDescriptionFile(path + "meta.json", "echoes"); + } + /** * Gets the underlying `BaseType`, if available. */