If I get a class, is it able to create a "typedef" for it?

25 views
Skip to first unread message

Freewind

unread,
Jan 21, 2013, 3:19:30 AM1/21/13
to haxe...@googlegroups.com
Hi, all:

    If I have a class, e.g.

    class User {
        var name:String,
        public function hello() {}
    }

Is it possible to create a "typedef" which takes "User" as example, during compilation period (with macro)? The "typedef" looks like:

    {
        name:String,
        hello: Void -> Void
    }


Juraj Kirchheim

unread,
Jan 21, 2013, 3:28:12 AM1/21/13
to haxe...@googlegroups.com
In fact the anonymous type you provided will not take User, because for User, hello doesn't allow write access.

But yes, in general there's a number of ways to do this. In your case (assuming that you want this for your angular.js stuff) you can simply get all instance fields and the type you want is TAnonymous(instanceFields).

Regards,
Juraj

Freewind

unread,
Jan 21, 2013, 4:21:32 AM1/21/13
to haxe...@googlegroups.com
Thank you, it should be the one I'm looking for
Reply all
Reply to author
Forward
0 new messages