Haxe API Documentation
Back | Index
class haxe.macro.Context
Available in neko
This is an API that can be used by macros implementations.
static function addResource(name : String, data : haxe.io.Bytes) : Void
Add or modify a resource that will be accessible with haxe.Resource api.
static function currentPos() : Position
Returns the position at which the macro is called
static function defineType(t : TypeDefinition) : Void
Define a new type based on the given definition.
static function defined(s : String) : Bool
Tells is the given compiler directive has been defined with -D
static function definedValue(key : String) : String
Returns the value defined through -D key=value
static function error(msg : String, pos : Position) : Dynamic
Display a compilation error at the given position in code and abort the current macro call
static function follow(t : Type, ?once : Bool) : Type
Follow all typedefs to reach the actual real type
static function getBuildFields() : Array<Field>
Returns the list of fields for the current type inside the build macro.
static function getClassPath() : Array<String>
Return the current classpath
static function getLocalClass() : Null<Ref<ClassType>>
Returns the current class in which the macro is called
static function getLocalMethod() : Null<String>
Returns the name of the method from which the macro was called
static function getLocalType() : Null<Type>
Returns the current type in/on which the macro is called
static function getLocalUsing() : Array<Ref<ClassType>>
Returns classes which are available for "using" where the macro was called
static function getLocalVars() : haxe.ds.StringMap<Type>
Returns local variables accessible where the macro was called
static function getModule(name : String) : Array<Type>
Return the list of types defined in the given compilation unit module
static function getPosInfos(p : Position) : { min : Int, max : Int, file : String}
Get the informations stored into a given position.
static function getType(name : String) : Type
Resolve a type from its name.
static function getTypedExpr(t : TypedExpr) : Expr
Return the raw expression corresponding to the given typed expression.
static function makeExpr(v : Dynamic, pos : Position) : Expr
Build an expression corresponding to the given runtime value. Only basic types + enums are supported.
static function makePosition(inf : { min : Int, max : Int, file : String}) : Position
Build a position with the given informations.
static function onGenerate(callb : Array<Type> -> Void) : Void
Set a callback function that will return all the types compiled before they get generated.
static function onMacroContextReused(callb : Void -> Bool) : Void
Register a callback function that will be called everytime the macro context cached is reused with a new compilation. This enable to reset some static vars since the code might have been changed. If the callback returns false, the macro context is discarded and another one is created.
static function onTypeNotFound(callb : String -> TypeDefinition) : Void
Set a callback function that will be called when a type cannot be found.
static function parse(expr : String, pos : Position) : Expr
Parse a constructed string into the corresponding expression.
static function parseInlineString(expr : String, pos : Position) : Expr
Parse a string contained into source code into the corresponding expression. Errors positions are reported within this string
static function registerModuleDependency(modulePath : String, externFile : String) : Void
Manually add a dependency between a module and a third party file : make sure the module gets recompiled (if it was cached) in case the extern file has been modified as well.
static function registerModuleReuseCall(modulePath : String, macroCall : String) : Void
Add a macro call to perform in case the module is reused by the compilation cache.
static function resolvePath(file : String) : String
Resolve a filename based on current classpath.
static function signature(v : Dynamic) : String
Quickly build an hashed MD5 signature for any given value
static function toComplexType(t : Type) : Null<ComplexType>
Returns the ComplexType corresponding to the given Type.
static function typeof(e : Expr) : Type
Evaluate the type a given expression would have in the context of the current macro call.
static function unify(t1 : Type, t2 : Type) : Bool
Returns true if t1 and t2 unify, false otherwise
static function warning(msg : String, pos : Position) : Void
Display a compilation warning at the given position in code
Back | Index