ruby-changes:31340
From: nobu <ko1@a...>
Date: Fri, 25 Oct 2013 14:18:30 +0900 (JST)
Subject: [ruby-changes:31340] nobu:r43419 (trunk): range.c: setter macros
nobu 2013-10-25 14:18:26 +0900 (Fri, 25 Oct 2013) New Revision: 43419 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43419 Log: range.c: setter macros * range.c (RANGE_SET_{BEG,END,EXCL}): add setter macros which wrap RSTRUCT_SET() and index. Modified files: trunk/range.c Index: range.c =================================================================== --- range.c (revision 43418) +++ range.c (revision 43419) @@ -25,12 +25,15 @@ static ID id_cmp, id_succ, id_beg, id_en https://github.com/ruby/ruby/blob/trunk/range.c#L25 #define RANGE_BEG(r) (RSTRUCT(r)->as.ary[0]) #define RANGE_END(r) (RSTRUCT(r)->as.ary[1]) #define RANGE_EXCL(r) (RSTRUCT(r)->as.ary[2]) +#define RANGE_SET_BEG(r, v) (RSTRUCT_SET(r, 0, v)) +#define RANGE_SET_END(r, v) (RSTRUCT_SET(r, 1, v)) +#define RANGE_SET_EXCL(r, v) (RSTRUCT_SET(r, 2, v)) #define EXCL(r) RTEST(RANGE_EXCL(r)) static inline VALUE SET_EXCL(VALUE r, VALUE v) { - RSTRUCT_SET(r, 2, v); + RANGE_SET_EXCL(r, v); return v ? Qtrue : Qfalse; } @@ -64,8 +67,8 @@ range_init(VALUE range, VALUE beg, VALUE https://github.com/ruby/ruby/blob/trunk/range.c#L67 } SET_EXCL(range, exclude_end); - RSTRUCT_SET(range, 0, beg); - RSTRUCT_SET(range, 1, end); + RANGE_SET_BEG(range, beg); + RANGE_SET_END(range, end); } VALUE @@ -1239,9 +1242,9 @@ range_loader(VALUE range, VALUE obj) https://github.com/ruby/ruby/blob/trunk/range.c#L1242 rb_raise(rb_eTypeError, "not a dumped range object"); } - RSTRUCT_SET(range, 0, rb_ivar_get(obj, id_beg)); - RSTRUCT_SET(range, 1, rb_ivar_get(obj, id_end)); - RSTRUCT_SET(range, 2, rb_ivar_get(obj, id_excl)); + RANGE_SET_BEG(range, rb_ivar_get(obj, id_beg)); + RANGE_SET_END(range, rb_ivar_get(obj, id_end)); + RANGE_SET_EXCL(range, rb_ivar_get(obj, id_excl)); return range; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/