Questions tagged [vapi]

Vala API files (.vapi) are used to map the Vala code to C.

is designed to allow access to existing libraries, especially based libraries, without the need for runtime bindings. Each to be used library requires a Vala API file (.vapi) at compile-time, containing the class and method declarations in Vala syntax.

27 questions
11
votes
4 answers

Vala vapi files documentation

I'd like to hack on an existing GLib based C project using Vala. Basically what I'm doing is, at the beginning of my build process, using valac to generate .c and .h files from my .vala files and then just compiling the generated files the way I…
Jordan
  • 1,599
  • 4
  • 26
  • 42
4
votes
1 answer

How do I specify that user data is provided before the callback parameter in Vala?

I have a C API that looks like this: typedef void (*cprcen_channel_callback) (CPRC_abuf *abuf, void *user_data); int CPRCEN_engine_set_callback(CPRCEN_engine *eng, CPRCEN_channel_handle chan, void *userdata, cprcen_channel_callback…
David Brown
  • 35,411
  • 11
  • 83
  • 132
4
votes
1 answer

How to create and using vapi files?

I want to make a custom vapi file, I have the basic stuff but I obviously miss something and I can't find anywhere how to do this properly. My main goal is to create a torent app, using libtorrent, and create the GUI (the frontend?) with vala and…
Levi
  • 317
  • 4
  • 15
3
votes
1 answer

How to use a fixed size C array type in vala?

Assume I have a C code (dcomplex.h): typedef double dcomplex[2]; and want to use such a data type in vala. What can be the minimal vapi file and vala call for it? (The ultimate goal is to use the C99 complex.h types.) I tried many variants of the…
3
votes
1 answer

How to write void pointer typedefs in vapi files?

I'm trying to write a VAPI file to use unixODBC, one of the functions is called SQLAllocHandle: // From #define SQL_API typedef signed short int SQLSMALLINT; typedef SQLSMALLINT SQLRETURN; typedef void * SQLHANDLE; //…
Jens Mühlenhoff
  • 14,565
  • 6
  • 56
  • 113
3
votes
1 answer

Parameters to use in a Vapi definition for passing arrays by reference

I have the following C code that uses libmodbus to read a single device register using ModbusTCP: modbus_t *ctx; uint16_t tab_reg[16]; ctx = modbus_new_tcp("10.0.1.77", 502); modbus_read_registers(ctx, 0x20, 2, tab_reg); printf("reg = %d…
2
votes
1 answer

How to use C++ library in Vala

I want to use vega library for working on dicom files. Sample code from its website is as follows: #include #include "vega/dictionary/dictionary.h" #include "vega/dicom/file.h" int main() { // Set the dictionary file …
rnso
  • 23,686
  • 25
  • 112
  • 234
2
votes
2 answers

VAPI problems with GTK+ 3

I'm trying to compile some Vala on ArchLinux, and when I try to include the package gtk+-3.0, it seems GDK and GTK+ 2.0 are being included as well; valac --pkg gtk+-3.0 test.vala gives the following errors: gdk-2.0.vapi:8.3-8.28: error:…
Kara Brightwell
  • 2,529
  • 1
  • 21
  • 29
2
votes
1 answer

Create binding for #define pointer address

Creating some custom vapi defs with the help of the excellent write up in the Vala manual as my guide. But I'm not sure how to translate C function-like macros like these: // GPIO setup macros. Always use INP_GPIO(x) before using OUT_GPIO(x) or…
George Aslanis
  • 517
  • 4
  • 11
2
votes
1 answer

Valac missing generated header

I have two files, client.vala and lib.vapi. The VAPI defines a class (that would usually talk to C code): class Toplevel.Sub.CClass { public uint i; } And client.vala uses the class: class Toplevel.Sub.UserClass { public Toplevel.Sub.CClass…
Albert Tomanek
  • 387
  • 4
  • 13
2
votes
1 answer

valac --vapi --internal-vapi --fast-vapi

// Point.vala namespace Test { class Point { public const int MY_CONST = 123; public float x { get; set; } public float y { get; set; } } } There is a vala source file, 'Point.vala' --vapi valac --vapi=Point.vapi…
2
votes
2 answers

Controlling the ref type in a Vapi file

I'm trying to write a Vapi file for MessagePack and am having a couple of issues, the first being that the resulting msgpack_object_print is incorrect because of the reference type of one of the parameters. The header file expects void…
geoffjay
  • 413
  • 4
  • 13
2
votes
2 answers

What is the relationship between Vala VAPI and GObject Introspection?

First, some context: I'm a Python developer who has written a medium-sized application using PyGObject, taking advantage of GObject Introspection to access things like GSettings, etc. Some of my Python objects actually subclass GObject.GObject, so…
robru
  • 2,313
  • 2
  • 29
  • 38
1
vote
3 answers

Creating signals in vapi files

I'm trying to write a VAPI file to use libui (https://github.com/andlabs/libui) in Vala. I don't know how to connect events from the controls to vala signals. In the libui headers is, for example of closing a window, this method defined: …
ibinshoid
  • 31
  • 2
1
vote
1 answer

Problem on creating vala bindings (vapi) for libui

I'm trying to write a VAPI file to use libui (https://github.com/andlabs/libui) in Vala. This is my first try: [CCode (cheader_filename = "ui.h")] namespace LibUi { [CCode (cname = "uiInitOptions", cprefix = "ui", has_type_id = false)] public…
ibinshoid
  • 31
  • 2
1
2