Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added vala example with constructor that does not work #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions examples/vala/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This Example is forked from https://github.com/antono/vala-object

export LD_LIBRARY_PATH := $(shell pwd)
export GI_TYPELIB_PATH := $(shell pwd)

all: vala-object.so ValaObject-0.1.typelib

run: all run-node-js

run-node-js: all
node test.node.js

c-source:
valac --ccode object.vala

vala-object.so:
valac \
--enable-experimental \
-X -fPIC -X -shared \
--library=vala-object \
--gir=ValaObject-0.1.gir \
-o vala-object.so \
object.vala

ValaObject-0.1.typelib:
g-ir-compiler \
--shared-library=vala-object.so \
--output=ValaObject-0.1.typelib \
ValaObject-0.1.gir

clean:
rm -fr ValaObject-0.1.typelib vala-object.so ValaObject-0.1.gir vala-object.vapi object.c *~
19 changes: 19 additions & 0 deletions examples/vala/object.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* This Example is forked from https://github.com/antono/vala-object */
namespace ValaObject {
public void say_hello_to(string lang)
{
print(@"I love You, $lang!!!\n");
print("-- Vala\n\n");
}
public class ValaClass : Object {
public string name = "Vala Class";

public ValaClass(){
print("I'm the Constructor"); // FIXME Constructor dosn't work
}

public string append_to_name(string suffix) {
return @"$name $suffix";
}
}
}
12 changes: 12 additions & 0 deletions examples/vala/test.node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* To run this example just type "make run".
* This Example is forked from https://github.com/antono/vala-object
*/

var gir = require('../../gir');
var ValaObject = gir.load('ValaObject');

ValaObject.say_hello_to('Node.js');

var inst = new ValaObject.ValaClass(); // FIXME Constructor dosn't work
console.log(inst); // => {}
console.log(inst.append_to_name('called from Node.js'));