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



Oh god, they use opaque handlers.

See the orientdb type as a context. You might abstract or hide it with a
static global. Careful with the initalization of statics in vala. I am not
experienced with vapis, but i believe you can instantiate a static field in
a class within it.


On Sat, May 14, 2016 at 20:57 Daniel Brendle <grindhold skarphed org> wrote:

Hi, Guys

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

While analyzing the C-code i came across the functions which turned out
to work in a somewhat unexpected way.
Usually one has some struct, methods to create and free the struct and a
set of methods that operate on that struct. Such code can be converted
to VAPI bindings in a straightforward way.
However liborient keeps managing stuff like this:

 - One struct to represent a handle
 - One struct to represent a connection
 - A set of methods which operate on _both_ of the previously mentioned
structs.

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);

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?

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?

Thanks in Advance and a nice evening,
    grindhold


_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list



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