HaxeDoc2

(やまだぃちぅ) #1
24 }

25 }

26
27 class Main {
28 static public function main() { }
29 }


With both interfacesI1andI2having:autoBuildmetadata, the build macro is executed
twice for classC. We guard against duplicate processing by adding a custom:processedmeta-
data to the class, which can be checked during the second macro execution.

9.6.4 Type Parameters


9.7 Initialization macros


Initialization macros are invoked from command line by using the--macro callExpr(args)
command. This registers a callback which the compiler invokes after creating its context, but
before typing what was argument to-main. This then allows configuring the compiler in some
ways.
If the argument to--macrois a call to a plain identifier, that identifier is looked up in the
classhaxe.macro.Compilerwhich is part of the Haxe Standard Library. It comes with several
useful initialization macros which are detailed in itsAPI.
As an example, theincludemacro allows inclusion of an entire package for compilation, re-
cursively if necessary. The command line argument for this would then be--macro include(’some.pack’,
true).
Of course it is also possible to define custom initialization macros to perform various tasks be-
fore the real compilation. A macro like this would then be invoked via--macro some.Class.theMacro(args).
For instance, as all macros share the same context (9.1), an initialization macro could set the value
of a static field which other macros use as configuration.
Free download pdf