Open JumpLink opened 12 years ago
Hey, try GObject style constructor in vala. they worked for me:
https://live.gnome.org/Vala/Tutorial#GObject-Style_Construction
public class Person : Object {
/* Construction properties */
public string name { get; construct; }
public int age { get; construct set; }
public Person(string name) {
Object(name: name);
}
public Person.with_age(string name, int years) {
Object(name: name, age: years);
}
construct {
// do anything else
stdout.printf("Welcome %s\n", this.name);
}
}
juergbi says me that some gir bindings support vala-instantiation using _new functions by treating them like a static function. For example in ruby-gir-ffi it works, I think. So it would be cool If node-gir would also be able to. The information should all be in the vala-generated .gir.
This example is forked from https://github.com/antono/vala-object I've add an constructor to demonstrate that the constructor does not work.