Re: [Vala] Manual VAPI writing
Harry Van Haaren píše v Po 19. 07. 2010 v 21:45 +0100: Hey All, I had this working before, but due to Hard disk issues I lost the .vapi. Currently I have a vapi that will create the right types, initialize the object (and destroy it), but I cant figure the read function out anymore: // sf_count_tsf_read_float(SNDFILE *sndfile, float *ptr, sf_count_t items) ; [CCode (cname=sf_read_float)] public static count_t read_float(float *array,count_t numSamples); You don't want that to be a static method. Static means it doesn't work with an actual object instance. signature.asc Description: Toto je digitálně podepsaná část zprávy ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Manual VAPI writing
// sf_count_tsf_read_float(SNDFILE *sndfile, float *ptr, sf_count_t items) ; [CCode (cname=sf_read_float)] public static count_t read_float(float *array,count_t numSamples); You don't want that to be a static method. Static means it doesn't work with an actual object instance. jeezsh.. Should have seen that! Thank you! Working now. -Harry ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Manual VAPI writing
oops, forgot to reply to all. 2010/7/1, Abderrahim Kitouni a.kito...@gmail.com: Hi, 2010/6/30, Harry Van Haaren harryhaa...@gmail.com: Any pointers as to how to do this? Cheers, -Harry Use cprefix= - maybe you also need to set cname=int in order to have Vala know what to call the type of the values. Yes! Thanks, that worked a charm. Next stumbling block found: when opening a file, sf_open(...) is called. To close the file, sf_close(file) must be called. [CCode (cheader_filename=sndfile.h,cname =SNDFILE)] class Sndfile { [CCode (cname=sf_open, free_function=sf_close)] public Sndfile(string path, FileMode mode, out Info sf_info ); } free_function should be set on the class, not the constructor. Valac should probably warn on unreconized annotations. btw, your class should be compact. HTH, Abderrahim ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Manual VAPI writing
On Di, 2010-06-29 at 22:15 +0100, Harry Van Haaren wrote: Andrea wrote: if your intent is to bind ad use the add function your binding it's quite right, but can be simpler: [CCode (cheader_filename=bindMe.h)] namespace Math { [CCode (cname=add)] public static int add (int a, int b); } Thanks, that's what I needed to hear ;-) I'm working on a LibSndFile wrapper, that's the reason for learning wrapping. I've got the a small part working, but not much (yet). I'm compiling with valac --save-temps, and analysing the output to work out where my errors are. I'm getting stuck on enum types, that are *NOT* in a namespace. Eg: the name of the enum IS what to call that in the output C file. 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.. Any pointers as to how to do this? Cheers, -Harry Use cprefix= - maybe you also need to set cname=int in order to have Vala know what to call the type of the values. -- Julian Andres Klode - Debian Developer, Ubuntu Member See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/. ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Manual VAPI writing
Andrea wrote: if your intent is to bind ad use the add function your binding it's quite right, but can be simpler: [CCode (cheader_filename=bindMe.h)] namespace Math { [CCode (cname=add)] public static int add (int a, int b); } Thanks, that's what I needed to hear ;-) I'm working on a LibSndFile wrapper, that's the reason for learning wrapping. I've got the a small part working, but not much (yet). I'm compiling with valac --save-temps, and analysing the output to work out where my errors are. I'm getting stuck on enum types, that are *NOT* in a namespace. Eg: the name of the enum IS what to call that in the output C file. 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.. Any pointers as to how to do this? Cheers, -Harry ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list
Re: [Vala] Manual VAPI writing
Any pointers as to how to do this? Cheers, -Harry Use cprefix= - maybe you also need to set cname=int in order to have Vala know what to call the type of the values. Yes! Thanks, that worked a charm. Next stumbling block found: when opening a file, sf_open(...) is called. To close the file, sf_close(file) must be called. [CCode (cheader_filename=sndfile.h,cname =SNDFILE)] class Sndfile { [CCode (cname=sf_open, free_function=sf_close)] public Sndfile(string path, FileMode mode, out Info sf_info ); } Doesnt seem to work...? The C output is totally off, ie: // at top of file: #define _sndfile_unref0(var) ((var == NULL) ? NULL : (var = (sndfile_unref (var), NULL))) // where file.close() is called: _sndfile_unref0 (file); I think it must be something in the .vapi, because that C looks totally unrelated to: sf_close(file); ;-) Getting steadily closer... I can print values of the sample loaded from HD already... sound will be coming soon! -Harry ___ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list