Re: [Vala] problem with Object.get_class()



Any ideas? Is this a bug in Vala? Shouldn't x.get_class() return an instance
of ObjectClass ?

On Thu, Mar 3, 2011 at 10:54 PM, Maga Abdurakhmanov <maqdev gmail com>wrote:

Hi guys, can't use get_class() method to access Object properties at
runtime, what's wrong here:


public class Test1 : GLib.Object {
public string string_value { get; set; default = "yahoo!"; }
 public int int_value { get; set; default = 123456; }
}

public class TestObjectClass : GLib.Object {

 public static int main(string[] args) {

var t1 = new Test1();
 stdout.printf("%s %i\n", t1.string_value, t1.int_value);

Type t = t1.get_type();
 stdout.printf("t.name = %s\n", t.name());
 ObjectClass objectClass = t1.get_class();

if (objectClass == null) {
 stdout.printf("objectClass is null \n");
}
else {
 foreach (ParamSpec ps in objectClass.list_properties()) {
stdout.printf("field: %s\n", ps.name);
 }
}
 return 0;
}
}

Here is an output of vala:

/tmp/test.vala.TWXRRV.c: In function ‘_g_type_class_ref0’:
/tmp/test.vala.TWXRRV.c:212: warning: passing argument 1 of
‘g_type_class_ref’ makes integer from pointer without a cast
/usr/include/glib-2.0/gobject/gtype.h:678: note: expected ‘GType’ but
argument is of type ‘gpointer’
yahoo! 123456
t.name = Test1

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


Version of vala is Vala *0.11.5*

--
Sincerely,
Magomed




-- 
Sincerely,
Magomed


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