# Ruby/GIO style

**URL:** <https://www.ruby-forum.com/t/ruby-gio-style/175947>\
**Category:** Ruby-Gnome 2\
**Created:** [September 23, 2009, 2:11am UTC](https://www.ruby-forum.com/t/ruby-gio-style/175947 "2009-09-23T02:11:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kouhei\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f4b2a3/32.png) [@Kouhei\_S](https://www.ruby-forum.com/u/Kouhei_S)\
**Post date:** [September 23, 2009, 2:11am UTC](https://www.ruby-forum.com/t/ruby-gio-style/175947/1 "2009-09-23T02:11:50Z")

</div>

Hi,

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](http://ruby-gnome2.sourceforge.jp/hiki.cgi?How+to+Implement+Ruby-GNOME2)

And please don’t use DECLARE\*, DEF\ __, SCAN\__ family  
macros. Please keep coding style with other bindings.

If Ruby/GIO doesn’t follow the Ruby-GNOME2 style guideline,  
we may remove it from the Ruby-GNOME2 project. :\<

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Kouhei\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f4b2a3/32.png) [@Kouhei\_S](https://www.ruby-forum.com/u/Kouhei_S)\
**Post date:** [September 23, 2009, 11:53am UTC](https://www.ruby-forum.com/t/ruby-gio-style/175947/2 "2009-09-23T11:53:53Z")

</div>

On Wed, Sep 23, 2009 at 02:14, Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](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?

---

<div class="post-metadata">

**Author:** ![Kouhei\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f4b2a3/32.png) [@Kouhei\_S](https://www.ruby-forum.com/u/Kouhei_S)\
**Post date:** [September 24, 2009, 12:02am UTC](https://www.ruby-forum.com/t/ruby-gio-style/175947/3 "2009-09-24T00:02:17Z")

</div>

> I am sorry to say that I donâ€™t have time to fix this right now. Is  
> someone else up to the task?

If I would be better at C, I would help and adapt it to conform to the  
styleguide, but I am quite sure if i touch the C code, things would  
break 🙂
