On Wed, Sep 23, 2009 at 02:14, Kouhei S. [email protected] wrote:
I looked Ruby/GIO source and noticed that it doesn’t follow
the Ruby-GNOME2 style guideline:
 http://ruby-gnome2.sourceforge.jp/hiki.cgi?How+to+Implement+Ruby-GNOME2
In what respect? I’ve followed it as far as I can tell.
And please don’t use DECLARE*, DEF_, SCAN_ family
macros. Please keep coding style with other bindings.
I realize that this may be controversial, but it’s so much simpler
this way and avoids a lot of errors by not having to repeat the same
junk every time. The bindings are already 5338 lines. Not using
these macros will make it a lot larger and, in my opinion, harder to
understand.
I mean, take functions that use SCAN_3_ARGS_WITH_BLOCK:
DECLARE_VARG(next_files_async)
{
int num_files;
int io_priority;
GCancellable *cancellable;
VALUE block;
SCAN_3_ARGS_WITH_BLOCK("12",
num_files, NUM2INT,
io_priority, RVAL2IOPRIORITYDEFAULT,
cancellable, RVAL2GCANCELLABLE);
g_file_enumerator_next_files_async(_SELF(self),
num_files,
io_priority,
cancellable,
rbgio_async_ready_callback,
(gpointer)block);
return self;
}
That would be
static VALUE
rbgio_im_next_files_async(int argc, VALUE *arg, VALUE self)
{
VALUE rbnum_files,
rbio_priority,
rbcancellable,
block;
int num_files;
int io_priority;
GCancellable *cancellable;
rb_scan_args(argc, argv, "12&",
&rbnum_files,
&rbio_priority, &rbcancellable,
&block);
num_files = NUM2INT(rbnum_files);
io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
cancellable = RVAL2GCANCELLABLE(rbcancellable);
SAVE_BLOCK(block);
if (!NIL_P(block))
G_CHILD_ADD(mGLib, block);
g_file_enumerator_next_files_async(_SELF(self),
num_files,
io_priority,
cancellable,
rbgio_async_ready_callback,
(gpointer)block);
return self;
}
OK, you don’t always need to do all the NUM2INT (and similar), but
sometimes order is important and then we have a problem if it is done
in different ways.
If Ruby/GIO doesn’t follow the Ruby-GNOME2 style guideline,
we may remove it from the Ruby-GNOME2 project. :<
I am sorry to say that I don’t have time to fix this right now. Is
someone else up to the task?