creationix / node-gir

Node bindings to libgirepository
http://live.gnome.org/GObjectIntrospection
MIT License
231 stars 58 forks source link

Added vala example with constructor that does not work #27

Open JumpLink opened 12 years ago

JumpLink commented 12 years ago

This example is forked from https://github.com/antono/vala-object I've add an constructor to demonstrate that the constructor does not work.

JumpLink commented 12 years ago

I've tested the example with Gjs and Seed and there it does not work, too. So It seems like it is not a problem coming from node-gir.

Is this a design decision for gir on Javascript or is the problem the generated .gir file?

antono commented 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);
    }
}
JumpLink commented 12 years ago

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.