[mb-devel] Re: Ruby bindings for libdiscid
Lukáš Lalinský
lalinsky at gmail.com
Tue Jun 5 07:17:37 UTC 2007
On Ut, 2007-06-05 at 01:00 +0200, Philipp Wolfer wrote:
> P.S.:It would be great if somebody with some Visual Studio experience
> could tell me, that the ugly, useless brackets I build into the source
> for MS compatibility are not really necessary ;-) Perhaps there is a
> better solution.
I'm not sure if C99 allows you to do variable declarations in the middle
of the code, but ANSI C doesn't. So if you want compatible C code, I'd
suggest to move them to the begin of a function:
static VALUE mb_discid_tracks(VALUE self)
{
DiscId *disc;
VALUE result; // Array of all [offset, length] tuples
VALUE tuple; // Array to store one [offset, length] tuple.
int track; // Track number
if (rb_iv_get(self, "@read") == Qfalse)
return Qnil;
else
{
Data_Get_Struct(self, DiscId, disc);
result = rb_ary_new();
track = discid_get_first_track_num(disc);
while (track <= discid_get_last_track_num(disc))
{
tuple = rb_ary_new3(2,
INT2FIX(discid_get_track_offset(disc, track)),
INT2FIX(discid_get_track_length(disc, track)) );
if (rb_block_given_p())
rb_yield(tuple);
else
rb_ary_push(result, tuple);
track++;
}
if (rb_block_given_p())
return Qnil;
else
return result;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Toto je =?ISO-8859-1?Q?digit=E1lne?=
=?ISO-8859-1?Q?_podp=EDsan=E1?= =?UTF-8?Q?_=C4=8Das=C5=A5?=
=?ISO-8859-1?Q?_spr=E1vy?=
Url : http://lists.musicbrainz.org/pipermail/musicbrainz-devel/attachments/20070605/e2a82ec3/attachment.pgp
More information about the MusicBrainz-devel
mailing list