Skip to content

Added vala example with constructor that does not work#27

Open
JumpLink wants to merge 1 commit into
creationix:masterfrom
JumpLink:master
Open

Added vala example with constructor that does not work#27
JumpLink wants to merge 1 commit into
creationix:masterfrom
JumpLink:master

Conversation

@JumpLink

@JumpLink JumpLink commented Aug 3, 2012

Copy link
Copy Markdown

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

JumpLink commented Aug 3, 2012

Copy link
Copy Markdown
Author

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

antono commented Aug 5, 2012

Copy link
Copy Markdown
Contributor

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

JumpLink commented Aug 5, 2012

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants