[前][次][番号順一覧][スレッド一覧]

ruby-changes:54132

From: mrkn <ko1@a...>
Date: Wed, 12 Dec 2018 16:16:16 +0900 (JST)
Subject: [ruby-changes:54132] mrkn:r66353 (trunk): enumerator.c: Add rb_arithmetic_sequence_components_t

mrkn	2018-12-12 16:16:07 +0900 (Wed, 12 Dec 2018)

  New Revision: 66353

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66353

  Log:
    enumerator.c: Add rb_arithmetic_sequence_components_t
    
    Add rb_arithmetic_sequence_components_t struct for encapsulating
    the components of ArithmeticSequence.

  Modified files:
    trunk/enumerator.c
    trunk/include/ruby/intern.h
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 66352)
+++ include/ruby/intern.h	(revision 66353)
@@ -244,7 +244,13 @@ VALUE rb_enumeratorize_with_size(VALUE, https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L244
 	    return SIZED_ENUMERATOR(obj, argc, argv, size_fn);		\
     } while (0)
 #define RETURN_ENUMERATOR(obj, argc, argv) RETURN_SIZED_ENUMERATOR(obj, argc, argv, 0)
-int rb_arithmetic_sequence_extract(VALUE, VALUE *, VALUE *, VALUE *, int *);
+typedef struct {
+    VALUE begin;
+    VALUE end;
+    VALUE step;
+    int exclude_end;
+} rb_arithmetic_sequence_components_t;
+int rb_arithmetic_sequence_extract(VALUE, rb_arithmetic_sequence_components_t *);
 /* error.c */
 VALUE rb_exc_new(VALUE, const char*, long);
 VALUE rb_exc_new_cstr(VALUE, const char*);
Index: enumerator.c
===================================================================
--- enumerator.c	(revision 66352)
+++ enumerator.c	(revision 66353)
@@ -2778,20 +2778,20 @@ arith_seq_exclude_end_p(VALUE self) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L2778
 }
 
 int
-rb_arithmetic_sequence_extract(VALUE obj, VALUE *begin, VALUE *end, VALUE *step, int *exclude_end)
+rb_arithmetic_sequence_extract(VALUE obj, rb_arithmetic_sequence_components_t *component)
 {
     if (rb_obj_is_kind_of(obj, rb_cArithSeq)) {
-        *begin = arith_seq_begin(obj);
-        *end   = arith_seq_end(obj);
-        *step  = arith_seq_step(obj);
-        *exclude_end = arith_seq_exclude_end_p(obj);
+        component->begin = arith_seq_begin(obj);
+        component->end   = arith_seq_end(obj);
+        component->step  = arith_seq_step(obj);
+        component->exclude_end = arith_seq_exclude_end_p(obj);
         return 1;
     }
     else if (rb_obj_is_kind_of(obj, rb_cRange)) {
-        *begin = RANGE_BEG(obj);
-        *end   = RANGE_END(obj);
-        *step  = INT2FIX(1);
-        *exclude_end = RTEST(RANGE_EXCL(obj));
+        component->begin = RANGE_BEG(obj);
+        component->end   = RANGE_END(obj);
+        component->step  = INT2FIX(1);
+        component->exclude_end = RTEST(RANGE_EXCL(obj));
         return 1;
     }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]