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 have your classes implements haxe.rtti.Infos. 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 implements haxe.rtti.Infos {
    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);
        trace(infos);
    }
}

See the XmlParser API for more information.

version #10246, modified 2011-03-05 00:04:57 by Smidoid