Re: [Vala] True vala introspection



On Wed, Jul 9, 2008 at 6:37 PM, Michael Lawrence <mflawren fhcrc org> wrote:
Maybe something like object.get_type().class_peek()? But perhaps there's a
shorter way...
Doesn't work for me:

$ cat <<END_OF_SOURCE >list_prop.vala ; valac list_prop.vala && ./list_prop
/* list_prop.vala */
using GLib;
public class Foo : Object {
   public string name ;
   public int count;
   static void main (string[] args) {
       Object foo = new Foo();
       var typ = foo.get_type();
       stdout.printf( "type = %s\n", typ.qname().to_string());
       var cls = typ.class_peek();
       var obj = (ObjectClass)cls ;
       foreach (var prp in obj.list_properties()) {
           stdout.printf( "  prp = %p\n" , prp);
       }
   }
}
END_OF_SOURCE

list_prop.c: In function 'foo_main':
list_prop.c:29: warning: passing argument 1 of 'g_type_class_ref'
makes integer from pointer without a cast
list_prop.c:31: warning: passing argument 1 of 'g_type_class_ref'
makes integer from pointer without a cast
type = Foo

(process:1160): GLib-GObject-WARNING **: cannot retrieve class for
invalid (unclassed) type `(null)'

(process:1160): GLib-GObject-CRITICAL **:
g_object_class_list_properties: assertion `G_IS_OBJECT_CLASS (class)'
failed

So is this a bug in vala? Or rather a missing functionality in GLib/GTK+ ?

Be seeing you,

Andreas Sliwka



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]