Extending Ruby with C
Subject:   Use rb_scan_args()
Date:   2004-11-19 15:40:58
From:   djberg96
You should do manual argument counting in variable length argument lists. Use rb_scan_args() instead. In writer_begin_element() for example, it should look like this:

static VALUE
writer_begin_element (int argc, VALUE *argv, VALUE self)
genxWriter w;
VALUE rbName, rbXmlns;

/* One mandatory, one optional argument */

if(Qnil != rbXmlns)

The front end API would then be:


This is more concise, and less prone to error than checking argc manually.

Main Topics Oldest First

Showing messages 1 through 2 of 2.

  • Use rb_scan_args()
    2004-11-19 15:44:38  rooneg [View]

    Thanks for the pointer, when I get a chance I'll make those changes to the current version of GenX4r.
  • Use rb_scan_args()
    2004-11-19 15:44:27  djberg96 [View]

    You should NOT do ...

    Give me a preview button!