Skip to content

Haxe Low Level Notes

Low level boring stuff. ;-)

Macros

  • Initialization Macros: These are provided by command line using the --macro compiler parameter. They are executed after the compiler arguments were processed and the typer context has been created, but before any typing was done (see Initialization Macros).
  • Build Macros: These are defined for classes, enums and abstracts through the @:build or @:autoBuild metadata. They are executed per type, after the type has been set up (including its relation to other types, such as inheritance for classes) but before its fields are typed (see Type Building).
  • Expression Macros: These are normal functions which are executed as soon as they are typed.

XML

1-20-2021

I have not heard any updates about XML literals in Haxe. I did spend an afternoon playing around with my prototype some more recently, though. I added support for event listeners containing Haxe code in the XML (like <Button click="trace('hi')"/>.

I tried adding a <Script> tag too, but I couldn’t find a way to directly copy the user’s code using a macro. Seems like they only support copying blocks of code and not full method signatures.

the main thing with the XML that I’m stuck on is trying to implement <Script>

See Also

Git

Haxe RTTI

Classes

  • Abstractdef- The abstract type runtime information.
  • CType - The runtime member types.
  • CTypeTools - The CTypeTools class contains some extra functionalities for handling CType instances.
  • ClassField - The runtime class field information.
  • Classdef - The runtime class definition information.
  • EnumField - The runtime enum constructor information.
  • Enumdef - The enum runtime type information.
  • FunctionArgument - The function argument runtime type information.
  • Meta - An API to access classes and enums metadata at runtime.
  • MetaData - The list of runtime metadata.
  • Path - The (dot-)path of the runtime type.
  • PathParams - The type parameters in the runtime type information.
  • Platforms - A list of strings representing the targets where the type is available.
  • Rights - Represents the runtime rights of a type.
  • Rtti - Rtti is a helper class which supplements the @:rtti metadata.
  • TypeApi - Contains type and equality checks functionalities for RTTI.
  • TypeInfos - The general runtime type information.
  • TypeParams - An array of strings representing the names of the type parameters the type has.
  • TypeRoot - Array of TypeTree.
  • TypeTree - The tree types of the runtime type.
  • Typedef - The typedef runtime information.
  • XmlParser - XmlParser processes the runtime type information (RTTI) which is stored as a XML string in a static field __rtti.

TypeTree

  • TPackage(name:String, full:String, subs:Array<TypeTree>)
  • TClassdecl(c:Classdef)
    • [Classdef]
    • tdynamic:Null<CType>
      • [CType]
      • CUnknown
      • CEnum(name:Path, params:Array<CType>)
      • CClass(name:Path, params:Array<CType>)
      • CTypedef(name:Path, params:Array<CType>)
      • CFunction(args:Array<FunctionArgument>, ret:CType)
        • [FunctionArgument]
        • optionalvalue:Null<String>
        • t:CType
        • opt:Bool
        • name:String
      • CAnonymous(fields:Array<ClassField>)
      • CDynamic(t:CType)
      • CAbstract(name:Path, params:Array<CType>)
    • superClass:Null<PathParams>
      • [PathParams]
      • path:Path //aias of// (String)
      • params:Array<CType>
    • statics:Array<ClassField>
    • platforms:Platforms //aias of// (Array<String>)
    • path:Path
    • params:TypeParams //aias of// (Array<String>)
    • module:Path
    • meta:MetaData //aias of// (Array<{params:Array<String>, name:String}>)
    • isPrivate:Bool
    • isInterface:Bool
    • isFinal:Bool
    • isExtern:Bool
    • interfaces:Array<PathParams>
    • file:Null<String>
    • fields:Array<ClassField>
      • [ClassField]
      • type:CType
      • set:Rights
        • [Rights]
        • RNormal
        • RNo
        • RCall(m:String)
        • RMethod
        • RDynamic
        • RInline
      • platforms:Platforms
      • params:TypeParams
      • overloads:Null<Array<ClassField>>
      • name:String
      • meta:MetaData
      • line:Null<Int>
      • isPublic:Bool
      • isOverride:Bool
      • isFinal:Bool
      • get:Rights
      • expr:Null<String>
      • doc:Null<String>
    • doc:Null<String>
  • TEnumdecl(e:Enumdef)
    • platforms:Platforms
    • path:Path
    • params:TypeParams
    • module:Path
    • meta:MetaData
    • isPrivate:Bool
    • isExtern:Bool
    • file:Null<String>
    • doc:Null<String>
    • constructors: Array<EnumField>
  • TTypedecl(t:Typedef)
    • types:Map<String, CType>
    • type:CType
    • platforms:Platforms
    • path:Path
    • params:TypeParams
    • module:Path
    • meta:MetaData
    • isPrivate:Bool
  • TAbstractdecl(a:Abstractdef)
    • to:Array<{t:CType, field:Null<String>}>
    • platforms:Platforms
    • path:Path
    • params:TypeParams
    • module:Path
    • meta:MetaData
    • isPrivate:Bool
    • impl:Classdef
    • from:Array<{t:CType, field:Null<String>}>
    • file:Null<String>
    • doc:Null<String>
    • athis:CType

See Also

Native Extensions

Ammer

class Adder extends Library<"adder"> {
public static function add_numbers(a:Int, b:Int):Int;
public static function load_file(filename:String, loaded:SizeOfReturn):Bytes;
public static function concat_strings(a:String, b:String):String;
public static function reverse_bytes(data:Bytes, dataLen:SizeOf<"data">):SameSizeAs<Bytes, "data">;
}
Terminal window
$ haxelib dev ammer <path to clone>
$ cd ammer/samples/poc/native
# <compile the native library somehow, preferably place it in /usr/local/lib or equivalent>
$ cd ..
$ haxe build-hl.hxml
$ hl bin/hl/sample.hl

ammer assumes you have a dynamic library and its headers.

See Also

Resources