Runtime Type Informations

Runtime type information is useful if you need to know at Runtime the exact way your classes were declared in your code.

In order to have this extra information accessible, you simply need to add @:rtti metadata to your class definition. This information is stored in an hidden __rtti static field and can be parsed into Xml to be processed using the haxe.rtti API :

class Test {
    var v : String;
    static function f() {
        return 33;
    static function main() {
        var rtti : String = untyped Test.__rtti;
        var x = Xml.parse(rtti).firstElement();
        var infos = new haxe.rtti.XmlParser().processElement(x);

See the XmlParser API for more information.

NOTE: In Haxe 2 instead of the @:rtti metadata you need to to have your classes implement haxe.rtti.Infos.

version #19574, modified 2013-07-10 23:46:04 by nadako