Re: [Vala] Manual VAPI writing



On Tue, 2010-06-29 at 22:15 +0100, Harry Van Haaren wrote:



enum
{    /* True and false */
    SF_FALSE    = 0,
    SF_TRUE        = 1,
    /* Modes for opening files. */
    SFM_READ    = 0x10,
    SFM_WRITE    = 0x20,
    SFM_RDWR    = 0x30,
    SF_AMBISONIC_NONE        = 0x40,
    SF_AMBISONIC_B_FORMAT    = 0x41
} ;

Is the one I'm stuck on now. I tried this in the .vapi:
class Sndfile
{ // all other functions ommitted for brevity
    [CCode (cname="")]
    public enum FileMode
    {    /* True and false */
        SF_FALSE    = 0,
        SF_TRUE        = 1,
        /* Modes for opening files. */
        SFM_READ    = 0x10,
        SFM_WRITE    = 0x20,
        SFM_RDWR    = 0x30,
        SF_AMBISONIC_NONE        = 0x40,
        SF_AMBISONIC_B_FORMAT    = 0x41
    }
}

but the C output goes like so  SNDFILE_FILE_MODE_SFM_READ  while I
want SFM_READ.
I hoped that the  cname=""  would clear the SNDFILE_FILE_MODE_  from
the start but it didnt..

Hi,

what a bad enum: it seems more as an aggregate of constants!

Attached you can find an example vapi, but be aware that I haven't
tested it.

Here a vala snippet to test it:

using SndFile;

int main()
{
        var fm = FileMode.READ;
        var info = Info ();
        var file = File.open ("test.wav", fm, ref info);
        return 0;
}


You can look also at the posix.vapi (/usr/share/vala/vapi/posix.vapi).

Regards,
        Andrea


Attachment: sndfile.vapi
Description: Text Data



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