From 58012254aadc7c7ef714ded3c3161a07c26aa1dc Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Fri, 3 Aug 2012 18:38:50 +0200 Subject: [PATCH] added vala example --- examples/vala/Makefile | 32 ++++++++++++++++++++++++++++++++ examples/vala/object.vala | 19 +++++++++++++++++++ examples/vala/test.node.js | 12 ++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 examples/vala/Makefile create mode 100644 examples/vala/object.vala create mode 100644 examples/vala/test.node.js diff --git a/examples/vala/Makefile b/examples/vala/Makefile new file mode 100644 index 0000000..3b941e3 --- /dev/null +++ b/examples/vala/Makefile @@ -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 *~ diff --git a/examples/vala/object.vala b/examples/vala/object.vala new file mode 100644 index 0000000..ab72644 --- /dev/null +++ b/examples/vala/object.vala @@ -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"; + } + } +} diff --git a/examples/vala/test.node.js b/examples/vala/test.node.js new file mode 100644 index 0000000..7441eeb --- /dev/null +++ b/examples/vala/test.node.js @@ -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'));