[Vala] predefined strings and vapi files



Hi!

I have started coding with vala and I really like it! Great work! It is
really a big step ahead compared to plain C gtk programming.

But I have some questions:

1) I often use some preprocessor strings in my C code like __DATE__
__TIME__. Is this feature also available in vala?

2) Something more complicated. I want to write a vapi file for the
tremor integer vorbis lib. As far I understand, I have to make a class
file of every struct I want to use. But I must only put the interesting
stuff of the c struct inside the class file, because every class is
translated to the complete c-struct at compile time.

I have the following c-calls: (OggVorbis_File is the basic typedef'd
struct)

extern int ov_clear(OggVorbis_File *vf);
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,longibytes);
extern long ov_bitrate(OggVorbis_File *vf);

I want to write a vapi which lets me act like that:

var ov = new OggVorbisFile();
ov.open("test.ogg");
bitrate = ov.get_bitrate();

and it should be translated to something like that: (Pseudocode)

ov = g_malloc(sizeof(OggVorbis_File)); 
FILE f = g_fopen("test.ogg","r"); 
ov_open(f,ov,NULL,NULL);
bitrate = ov_bitrate(ov);
...
ov_clear(ov);
g_free(ov);

Can vapi does this for me or do I have to write some c stubs or better a
vala class. How do I enable error handling with try {...} catch if the
file could not be opened?
Maybe the best will be that I define a basic class with vapi to access
the c-lib-calls and put everything else in a derived vala class which
handels errors and more.

Thanks for any help, -Klaus




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