Re: [Vala] Vapi bindings and a weird C-pattern



From: Daniel Brendle <grindhold skarphed org>

Sent: Sunday, 15 May 2016, 0:52
Subject: [Vala] Vapi bindings and a weird C-pattern

I want to write VAPI bindings for liborient [0].

For reference this is:
https://github.com/dam2k/liborient/blob/master/include/liborient/liborient.h



A typical method-definition looks like this:> 
long o_bin_dataclustercount(orientdb *o, orientdb_con *c, struct timeval
*timeout, int nonblocking, short clusternumber);

In Vala I'd like to use the lib like this:
var handle = new OrientDB();
var connection = handle.connect("foo","bar");
connection.dataclustercount(sometimeval, 1, 1);

The only thing I could think of was connection being a nested class.
Similar to an iterator:
https://wiki.gnome.org/Projects/Vala/Tutorial#CA-da256d2dad8b53fad2ae12a6292bfe22240a3fb5

Not sure if this works with a VAPI, but I would like to know if it does.

Under the given circumstances I have the feeling that the best thing one
can achieve is something like this:

var handle = new OrientDB();
var connection = Connection.connect(handle, "foo", "bar")
handle.dataclustercount(connection, sometimeval, 1, 1);

Am I right? Is there any possibility to cover this C-Pattern?


That would be my understanding as well. 


Second question: The library imports <sys/time.h> at some point and uses
the timeval definition from in there in method signatures. How can i

write equivalent Vala Types to write Vala signatures for them?

I believe timeval is Posix only, so you need:
http://valadoc.org/#!api=posix/Posix.timeval
Al


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]