macro.Compiler
Compiler
package haxe-macro
Available on all platformsAll these methods can be called for compiler configuration macros.
Static methods
static addClassPath (path:String):Void
Available on macro, neko
static addGlobalMetadata (pathFilter:String, meta:String, recursive:Bool = true, toTypes:Bool = true, toFields:Bool = false):Void
Available on macro, neko
Adds metadata meta
to all types (if toTypes = true
) or fields (if toFields = true
) whose dot-path matches pathFilter
.
If recursive
is true a dot-path is considered matched if it starts with pathFilter
. This automatically applies to path filters of packages. Otherwise an exact match is required.
If pathFilter
is the empty String ""
it matches everything (if recursive = true
) or only top-level types (if recursive = false
).
This operation has no effect if the type has already been loaded, e.g. through Context.getType
.
static addMetadata (meta:String, className:String, ?field:String, ?isStatic:Bool):Void
Available on macro, neko
Add metadata to a (static) field or class by name. An error is thrown when className
or field
is invalid.
static addNativeArg (argument:String):Void
Available on macro, neko
Adds an argument to be passed to the native compiler (e.g. -javac-arg
for Java).
static addNativeLib (name:String):Void
Available on macro, neko
Adds a native library depending on the platform (e.g. -swf-lib
for Flash).
static allowPackage (v:String):Void
Available on macro, neko
static define (flag:String, ?value:String):Void
Available on macro, neko
Set a conditional compiler flag.
static exclude (pack:String, rec:Bool = true):Void
Available on macro, neko
Exclude a specific class, enum, or all classes and enums in a package from being generated. Excluded types become extern
.
Parameters:
rec |
If true, recursively excludes all sub-packages. |
---|
static excludeFile (fileName:String):Void
Available on macro, neko
Exclude classes and enums listed in an extern file (one per line) from being generated.
static getDefine (key:Dynamic):Dynamic
A conditional compiler flag can be set command line using -D key=value
.
Returns the value of a compiler flag.
If the compiler flag is defined but no value is set, Compiler.getDefine
returns "1"
(e.g. -D key
).
If the compiler flag is not defined, Compiler.getDefine
returns null
.
See:
static getDisplayPos ():Null<{pos:Int, file:String}>
Available on macro, neko
static getOutput ():String
Available on macro, neko
static include (pack:String, rec:Bool = true, ?ignore:Array<String>, ?classPaths:Array<String>, strict:Bool = false):Void
Available on macro, neko
Includes all modules in package pack
in the compilation.
In order to include single modules, their paths can be listed directly on command line: haxe ... ModuleName pack.ModuleName
.
By default Compiler.include
will search for modules in the directories defined with -cp
. If you want to specify a different set of paths to search for modules, you can use the optional argument classPath
.
Parameters:
rec |
If true, recursively adds all sub-packages. |
---|---|
ignore |
Array of module names to ignore for inclusion. |
classPaths |
An alternative array of paths (directory names) to use to search for modules to include. Note that if you pass this argument, only the specified paths will be used for inclusion. |
strict |
If true and given package wasn't found in any of class paths, fail with an error. |
static includeFile (file:Dynamic, position:Dynamic):Dynamic
Available on js, lua
Embed a JavaScript file at compile time (can be called by --macro
or within an __init__
method).
static includeFile (file:String, position:IncludePosition = Top):{pos:Position, expr:ExprDef}
Available on macro
Embed a JavaScript file at compile time (can be called by --macro
or within an __init__
method).
static keep (?path:String, ?paths:Array<String>, recursive:Bool = true):Void
Available on macro, neko
Marks types or packages to be kept by DCE.
This also extends to the sub-types of resolved modules.
In order to include module sub-types directly, their full dot path including the containing module has to be used (e.g. msignal.Signal.Signal0
).
This operation has no effect if the type has already been loaded, e.g. through Context.getType
.
Parameters:
path |
A package, module or sub-type dot path to keep. |
---|---|
paths |
An Array of package, module or sub-type dot paths to keep. |
recursive |
If true, recurses into sub-packages for package paths. |
static patchTypes (file:String):Void
Available on macro, neko
Load a type patch file that can modify the field types within declared classes and enums.
static removeField (className:String, field:String, ?isStatic:Bool):Void
Available on macro, neko
Removes a (static) field from a given class by name. An error is thrown when className
or field
is invalid.
static setCustomJSGenerator (callb:JSGenApi ‑> Void):Void
Available on macro, neko
Change the default JS output by using a custom generator callback
static setFieldType (className:String, field:String, type:String, ?isStatic:Bool):Void
Available on macro, neko
Set the type of a (static) field at a given class by name. An error is thrown when className
or field
is invalid.
static setOutput (fileOrDir:String):Void
Available on macro, neko
© 2005–2016 Haxe Foundation
Licensed under a MIT license.
http://api.haxe.org/haxe/macro/Compiler.html