Skip to content

Commit

Permalink
Merge pull request #11 from JumpLink/master
Browse files Browse the repository at this point in the history
new valabind examples
  • Loading branch information
JumpLink committed Jul 17, 2013
2 parents e474ff3 + 62e6e21 commit 0771172
Show file tree
Hide file tree
Showing 43 changed files with 331 additions and 48 deletions.
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
*.so
*.gir
*.vapi
object.c
langs/javascript/node_modules/
*.c
*.h
*.i
*.cxx
*.php
*.py
*.js
node_modules
!gir/*/*
!swig/*/*
129 changes: 106 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,50 +1,133 @@
export LD_LIBRARY_PATH := $(shell pwd)
export GI_TYPELIB_PATH := $(shell pwd)

all: vala-object.so ValaObject-0.1.typelib
RUBY1.8_HEADERS=-I/usr/lib/ruby/1.8/x86_64-linux/ -I/usr/lib/ruby/1.8/i686-linux/
RUBY1.9.1_HEADERS=-I/usr/lib/ruby/1.9.1/x86_64-linux/ -I/usr/lib/ruby/1.9.1/i686-linux/
PHP_HEADERS=`php-config --includes`

run: all run-ruby run-python run-php run-lua run-gnome-js run-node-js
all: libobject.so ValaObject-0.1.typelib c-source

run-ruby: all
ruby langs/ruby/test.rb
run: run-gir

run-python: all
python langs/python/test.py
run-gir: run-gir-ruby run-gir-python run-gir-php run-gir-lua run-gir-gnome-js run-gir-nodejs

run-php: all
php langs/php/test.php
run-valabind: run-valabind-ruby run-valabind-python run-valabind-php run-valabind-lua run-gir-nodejs

run-perl: all
perl langs/perl/test.pl
########## test gir bingings ##########

run-lua: all
lua langs/lua/test.lua
luajit-2.0.0-beta9 langs/lua/test.lua
run-ruby-gir:
-ruby gir/ruby/test.rb

run-gnome-js: all
gjs langs/javascript/test.gnome.js
seed langs/javascript/test.gnome.js
run-python-gir:
-python gir/python/test.py

run-node-js: all
cd langs/javascript && npm install && node test.node.js
run-php-gir:
-php gir/php/test.php

run-perl-gir:
-perl gir/perl/test.pl

run-lua-gir:
-lua gir/lua/test.lua
-luajit-2.0.0-beta9 gir/lua/test.lua

run-gnome-js:
-gjs gir/javascript/test.gnome.js
-seed gir/javascript/test.gnome.js

run-nodejs-gir:
-node gir/javascript/test.node.js

########## test generated bindings with Valabind and valabind ##########

# TODO
run-ruby-valabind:
-make run -C valabind/ruby

# TODO
run-python-valabind:
-python valabind/python/test.py

run-php-valabind:
-make run -C valabind/php

# TODO
run-perl-valabind:
-perl valabind/perl/test.pl

# TODO
run-lua-valabind:
-lua valabind/lua/test.lua

run-nodejs-valabind:
-make run -C valabind/javascript

run-java-valabind:
-make run -C valabind/java

run-d-valabind:
-make run -C valabind/dlang

########## generate bindings with Valabind ##########

# TODO
ruby-valabind: libobject.so c-source
-make bind -C valabind/ruby

# TODO
python-valabind: libobject.so c-source
valabind-cc python pythonobject -NValaObject libobject.vapi -I. `pkg-config --cflags --libs gobject-2.0` -I/usr/include -L. -lobject -x

php-valabind:
-make bind -C valabind/php

# TODO
perl-valabind: libobject.so c-source
valabind-cc perl perlobject -NValaObject libobject.vapi -I. `pkg-config --cflags --libs gobject-2.0` -I/usr/include -L. -lobject -x

# TODO
lua-valabind: libobject.so c-source
valabind-cc lua luaobject -NValaObject libobject.vapi -I. `pkg-config --cflags --libs gobject-2.0` -I/usr/include -L. -lobject -x

nodejs-valabind:
-make bind -C valabind/javascript

java-valabind:
-make bind -C valabind/java

d-valabind-swig:
-make swig -C valabind/dlang

d-valabind:
-make bind -C valabind/dlang

########## Vala Stuff ##########

c-source:
valac --ccode object.vala
valac -H object.h -C --vapi=object.vapi --library=libobject object.vala

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

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

########## Other ##########

clean:
rm -fr $(shell cat .gitignore)
make clean -C valabind/javascript
make clean -C valabind/php
make clean -C valabind/ruby
make clean -C valabind/java
make clean -C valabind/dlang
make clean -C valabind/c++
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions langs/ruby/test.rb → gir/ruby/test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
require 'gir_ffi' # gem install gir_ffi

GirFFI.setup(:ValaObject)
require 'object.so' # gem install gir_ffi

ValaObject.say_hello_to('Ruby')

Expand Down
17 changes: 0 additions & 17 deletions langs/javascript/package.json

This file was deleted.

5 changes: 2 additions & 3 deletions object.vala
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
namespace ValaObject {
public void say_hello_to(string lang)
{
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 string append_to_name(string suffix) {
public string append_to_name (string suffix) {
return @"$name $suffix";
}
}
Expand Down
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "ValaObject",
"version": "0.0.1",
"url": "https://github.com/antono/vala-object",
"description": "",
"repository" : {"type": "git", "url": "[email protected]:antono/vala-object.git"},
"dependencies": {
"ref-struct": "0.0.4",
"ref": "~0.1.3",
"ffi": "~1.2.0",
"gir": "*"
}
}
25 changes: 25 additions & 0 deletions valabind/c++/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export LD_LIBRARY_PATH:=$(shell cd ../.. && pwd)

GOBJECT_HEADERS=`pkg-config --cflags --libs gobject-2.0`
LANGUAGE=cxx

run: build

bind: c-source libobject.so
valabind --$(LANGUAGE) -m vala_cpp_object -N ValaObject -V ../.. object -x

swig: c-source libobject.so
valabind-cc $(LANGUAGE) libobject -NValaObject ../../object.vapi -I. -I../../ -I/usr/include -I/usr/include/tcl8.6 $(GOBJECT_HEADERS) -L../.. -L/usr/lib/ -L/usr/local/lib -lobject -x

build:
gcc test.cpp vala_cpp_object.cxx -I. -I../../ -I/usr/include $(GOBJECT_HEADERS) -L../.. -lobject
#gcc test.cpp

c-source:
make c-source -C ../../

libobject.so:
make libobject.so -C ../../

clean:
rm -fr *.so *.i *.cxx object.d object_im.d *.out
1 change: 1 addition & 0 deletions valabind/c++/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo apt-get install libtclcl1-dev tcl8.6-dev
6 changes: 6 additions & 0 deletions valabind/c++/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "vala_cpp_object.cxx"

int main( ) {

return 0;
}
28 changes: 28 additions & 0 deletions valabind/dlang/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export LD_LIBRARY_PATH:=$(shell cd ../.. && pwd):$(shell pwd)
export SWIGFLAGS=-d2

GOBJECT_HEADERS=`pkg-config --cflags --libs gobject-2.0`
LANGUAGE=dlang

run: build-swig
./test

# TODO
bind: c-source libobject.so
valabind --$(LANGUAGE) -m object -N ValaObject -V ../.. object -o vala_d_object.d

swig: c-source libobject.so
valabind-cc d vala_d_object -NValaObject ../../object.vapi -I. -I../../ $(GOBJECT_HEADERS) -I/usr/include -L../.. -lobject -x
mv vala_d_object.so libvala_d_object_wrap.so

build-swig:
dmd test.d vala_d_object_im.d vala_d_object.d

c-source:
make c-source -C ../../

libobject.so:
make libobject.so -C ../../

clean:
rm -fr *.so *.i *.cxx *.o vala_d_object.d vala_d_object_im.d test
4 changes: 4 additions & 0 deletions valabind/dlang/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Install D Compiler and Libraries
===============

Just install D2: http://dlang.org/
9 changes: 9 additions & 0 deletions valabind/dlang/test.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import std.stdio;
import std.conv;
import vala_d_object;

void main() {
//say_hello_to ("Java");
auto vala_object = new ValaClass();
writefln (vala_object.append_to_name ("called from D"));
}
23 changes: 23 additions & 0 deletions valabind/java/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export LD_LIBRARY_PATH:=$(shell cd ../.. && pwd)

GOBJECT_HEADERS=`pkg-config --cflags --libs gobject-2.0`
HEADERS=-I/usr/lib/jvm/java-7-openjdk-amd64/include/ -I/usr/lib/jvm/java-7-openjdk-amd64/include/linux
LANGUAGE=java

run: *.class
java -Djava.library.path=. Test

bind: c-source libobject.so
valabind-cc $(LANGUAGE) libobject -NValaObject ../../object.vapi -I. -I../../ $(HEADERS) $(GOBJECT_HEADERS) -I/usr/include -L../.. -lobject -x

*.class:
javac *.java

c-source:
make c-source -C ../../

libobject.so:
make libobject.so -C ../../

clean:
rm -fr *.typelib *.so *.gir *.vapi *.c *.h *.i *.cxx *.class ValaClass.java libobjectJNI.java libobject.java
3 changes: 3 additions & 0 deletions valabind/java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apt-get install default-jdk

?libxt-doc openjdk-7-demo openjdk-7-source visualvm?
17 changes: 17 additions & 0 deletions valabind/java/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Run: java -Djava.library.path=. TestRBin */
import java.util.*;

class Test {
static {
System.loadLibrary("object");
}
public static void main (String args[]) {

// say_hello_to ("Java");

ValaClass vala_object;
vala_object = new ValaClass ();
System.out.printf (vala_object.append_to_name ("called from Java"));

}
}
21 changes: 21 additions & 0 deletions valabind/javascript/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export LD_LIBRARY_PATH:=$(shell cd ../.. && pwd)

GOBJECT_HEADERS=`pkg-config --cflags --libs gobject-2.0`

run:
node test.node.js

bind: c-source libobject.so node_modules
valabind --node-ffi -m object -N ValaObject -V ../.. object -o vala_node_object.js

c-source:
make c-source -C ../../

libobject.so:
make libobject.so -C ../../

node_modules:
npm install

clean:
rm -fr *.typelib *.so *.gir *.vapi *.c *.h *.i *.cxx vala_node_object.js node_modules
Loading

0 comments on commit 0771172

Please sign in to comment.