Re: [Vala] Using a C library



Al,

This is the essence of what you are doing - creating an interface between your
Vala code and the C code being generated.

It took me a while to appreciate and understand this statement. After
getting past the initial woes, I was starting to try to turn the vapi into
the full-fledged OOP bindings. You can even see that in my early code where
I was putting a method into the enum. (I had actually typed up a reply
asking about calling C functions directly before I realized that the
VAPI-layer needs to only be concerned with wrapping the library, and OOP
happens above that.) It's clear to me now that I need to write a vapi that
only maps the C functions/types/enums to Vala and do the user-friendly
classes separately.

Also, thanks for the info pkg-config. I'm not at my dev. machine right now,
and I think ultimately, I'm going to take the same approach of writing it
myself, so I can -- at least attempt -- to understand what's happening.

I did have a question about the C sp_error enum. There are 36 values [0-35]
in the C library, but there are some gaps such that the last value
(SYSTEM_FAILURE) is 41, not 35. Every once in a while in the C enum a
manual value is specified that jumps the integer a few places -- for
example:

 SP_ERROR_TRACK_NOT_PLAYABLE        = 3,
 SP_ERROR_BAD_APPLICATION_KEY       = 5,

I've tried a variety of solutions. If I don't specify any integer values in
Vala, then the codes don't respect the "jumps," meaning that
SP_ERROR_BAD_APPLICATION_KEY == 4. If I specify the "jumps" or all the
integers, then libspotify sp_error_message() complains about an invalid
type in a string (not a segfault or compilation error). Why isn't Vala
using the C values properly when not specified? Also, what's the possible
invalid type problem when specifying the integers? I don't feel like I'm
understanding whether it's a int-length (unsigned/long/etc.) issue or
something else. Any idea why the Vala enum isn't pulling the values
specified in libspotfiy/api.h?

Lastly, a question about gobject introspection. I'm totally clueless about
this. So my plan on my project is to release in 3-4/5 parts. The first part
will be the vapi, and a sensible OOP Vala library. The second part is Vala
program that provides a DBus interface to Spotify that obviously any
program could use. The third part is a GTK+ GUI program to interact with
the DBus interface. The fourth part is Gnome Gjs extension that interacts
with the DBus service. The last part, highly depending on popularity, is a
Unity and/or KDE extension that is a port of Gjs extension. Back to the
original question, is that first part (vapi + OOP library) applicable to
use by for GObject introspection or would they other programs need to
interface with the DBus service?

Reading back over my last mail, thanks for not taking that too severely. I
was banging my head against the wall and a little frustrated. I'm extremely
thankful for everyone's help and guidance.

Thanks,
Justin

On Tue, Apr 21, 2015 at 11:05 AM, Al Thomas <astavale yahoo co uk> wrote:

From: Abderrahim Kitouni <a kitouni gmail com>
Sent: Tuesday, 21 April 2015, 16:02
Subject: Re: [Vala] Using a C library
Le 21 avr. 2015 12:19, "Al Thomas" <astavale yahoo co uk> a écrit :
I've had a quick search and it looks as though a libspotify.pc file
exists, e.g.
[...]
you rename spotify.vala to spotify.vapi and try compiling with:
Shouldn't that be libspotify.vapi ?


Good point. VAPI name should match pkg-config name, otherwise you end up
with
problems like this:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=564088
https://mail.gnome.org/archives/commits-list/2010-October/msg01520.html
_______________________________________________
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]