haxe.rtti not working for the flash target?

33 views
Skip to first unread message

shvfn

unread,
Jan 13, 2013, 7:41:45 PM1/13/13
to haxe...@googlegroups.com
Hi everybody!

I need help, I can't access haxe.rtti.Meta for the flash-target. The windows-target via CPP works.

This code:

class Foo
{
    @fooparam
    var test : Int;

    public function new() {
    }
}


class Main
{  
    static public function main()
    {
        var foo = new Foo();
        var m = haxe.rtti.Meta.getFields( foo );
        trace( m );              
    }  
}


... fails for the flash target with an exception, something like "__meta__ is not available and there's no default value".


Something similar happens with haxe.rtti.Infos:

class Foo implements haxe.rtti.Infos
{
    @fooparam
    var test : Int;

    public function new() {
    }
}


class Main
{  
    static public function main()
    {
        var foo = new Foo();
       
        var rtti : String = untyped foo.__rtti;
        var x = Xml.parse(rtti).firstElement();
        var infos = new haxe.rtti.XmlParser().processElement(x);
        trace(infos);
    }  
}



This fails too with the same exception for the field '__rtti'.

And (whistling the X-files-theme): when debugging in FlashDevelop both fields are shown as static members of foo.

I use one of the newer Haxe-SVN-Versions (not the latest though, because it doesn't work with NME 3.5.3 anymore).

Does anybody have an idea what's wrong?

Simon Krajewski

unread,
Jan 13, 2013, 8:07:21 PM1/13/13
to haxe...@googlegroups.com
These functions expect a Class, not an instance. Try
haxe.rtti.Meta.getFields(Type.getClass(foo));

Simon

shvfn

unread,
Jan 14, 2013, 2:46:36 AM1/14/13
to haxe...@googlegroups.com
Aaaah, yes. Thanks Simon!
Reply all
Reply to author
Forward
0 new messages