Skip to content
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'));