After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 562070 - construct Block for GType based fundamental classes
construct Block for GType based fundamental classes
Status: RESOLVED NOTABUG
Product: vala
Classification: Core
Component: Objects
0.5.x
Other All
: Normal enhancement
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-23 23:36 UTC by rainwoodman
Modified: 2008-12-15 23:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
call constructor for gtype_based classes (8.78 KB, patch)
2008-11-23 23:37 UTC, rainwoodman
reviewed Details | Review

Description rainwoodman 2008-11-23 23:36:13 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;
}
Comment 1 rainwoodman 2008-11-23 23:37:15 UTC
Created attachment 123290 [details] [review]
call constructor for gtype_based classes

Not a big patch. But really useful to symmetrize GObject and GTypeInstance backends.
Comment 2 Jürg Billeter 2008-12-15 23:11:06 UTC
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.