Re: [Vala] Writing VAPI: How to call struct member?



From: "marcin saepia net" <marcin saepia net>
Sent: Monday, 8 August 2016, 13:49
Subject: [Vala] Writing VAPI: How to call struct member?


I am writing VAPI to the Java Native Interface.

This is very interesting because it would allow Vala

libraries to provide fast supporting functions for 

Android applications, including Webviews.

The use of Vala/Genie for developing libraries as 

performant plugins is an interesting use case. As community
understanding of this topic evolves it may get added to:
https://wiki.gnome.org/Projects/Vala/LibraryWriting

Some time ago I tried writing a VAPI for SQLite extensions.
This C header has a struct containing a large number of
function pointers mapped to with the same number of #defines:
https://www.sqlite.org/src/artifact/8648034aa702469a
I got as far as binding the struct as:
    [CCode (cname="sqlite3_api_routines")]
            public struct APIRoutines {}
Since then I have come across the interface keyword for VAPIs.
This appears in VAPIs generated by vapigen, but I'm starting to wonder
if this is also relevant to hand written bindings for collections
of function pointers in a struct. Most examples in the Vala
source inherit from GLib.Object, but a few don't. See MessageFilter in:
https://git.gnome.org/browse/vala/tree/vapi/libsoup-2.2.vapi#n381
and TypePlugin in:
https://git.gnome.org/browse/vala/tree/vapi/gobject-2.0.vapi#n395

This may be relevant because both JavaVM and JNIEnv are implementations
of JNINativeInterface.




I have there JavaVM struct.

In my function I get pointer to one.

I would like to call its member function, like this:

(*vm)->GetEnv(...)

When I define my VAPI in such way

 [CCode (cname = "JavaVM")]
 public struct JavaVM {
   [CCode (cname = "GetEnv")]
   public int get_env(out unowned Env env, Version version);
 }

I am getting C Code

GetEnv(vm, param1, param2)

instead of

(*vm)->GetEnv(param1, param2)

How can I write VAPI to achieve the second result in the C code?

Marcin
_______________________________________________
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]