GNOME Bugzilla – Bug 562070
construct Block for GType based fundamental classes
Last modified: 2008-12-15 23:11:06 UTC
class AAA { public AAA() { int i = 10; message ("AAA creation method invoked"); } construct { message ("AAA constructor invoked"); } } class BBB: AAA { public int j {get; construct;} private int m; public BBB() { base(); j = 100; message ("BBB creation method invoked"); } construct { m = 0; message ("BBB constructor invoked"); } } public int main(string[] args) { BBB b = new BBB(); return 0; }
Created attachment 123290 [details] [review] call constructor for gtype_based classes Not a big patch. But really useful to symmetrize GObject and GTypeInstance backends.
Thanks for the patch. However, I don't think it's a good idea to support construct blocks for non-GObject classes. If you want to use the GObject construction mechanism, you should really derive from GObject. I've committed a different change instead, valac will now report an error when trying to use construct blocks in non-GObject classes.