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

ruby-changes:67609

From: S-H-GAMELINKS <ko1@a...>
Date: Sun, 5 Sep 2021 23:01:48 +0900 (JST)
Subject: [ruby-changes:67609] bdd6d8746f (master): Replace RBOOL macro

https://git.ruby-lang.org/ruby.git/commit/?id=bdd6d8746f

From bdd6d8746f0a07b2c0cc3a6b387bf594569c0bb7 Mon Sep 17 00:00:00 2001
From: S-H-GAMELINKS <gamelinks007@g...>
Date: Tue, 31 Aug 2021 20:30:35 +0900
Subject: Replace RBOOL macro

---
 ast.c        |  4 ++--
 bignum.c     | 10 +++++-----
 compile.c    |  4 ++--
 dir.c        |  4 ++--
 enumerator.c |  2 +-
 file.c       | 28 ++++++++++++++--------------
 gc.c         |  8 ++++----
 iseq.c       |  2 +-
 numeric.rb   |  6 +++---
 parse.y      |  8 ++++----
 process.c    |  2 +-
 ractor.rb    |  2 +-
 ruby.c       |  2 +-
 time.c       |  2 +-
 transcode.c  |  2 +-
 15 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/ast.c b/ast.c
index 0b6791d..202527f 100644
--- a/ast.c
+++ b/ast.c
@@ -366,7 +366,7 @@ node_children(rb_ast_t *ast, const NODE *node) https://github.com/ruby/ruby/blob/trunk/ast.c#L366
       case NODE_WHILE:
       case NODE_UNTIL:
         return rb_ary_push(rb_ary_new_from_node_args(ast, 2, node->nd_cond, node->nd_body),
-                           (node->nd_state ? Qtrue : Qfalse));
+                           RBOOL(node->nd_state));
       case NODE_ITER:
       case NODE_FOR:
         return rb_ary_new_from_node_args(ast, 2, node->nd_iter, node->nd_body);
@@ -433,7 +433,7 @@ node_children(rb_ast_t *ast, const NODE *node) https://github.com/ruby/ruby/blob/trunk/ast.c#L433
                                     NEW_CHILD(ast, node->nd_args->nd_body));
       case NODE_OP_ASGN2:
         return rb_ary_new_from_args(5, NEW_CHILD(ast, node->nd_recv),
-                                    node->nd_next->nd_aid ? Qtrue : Qfalse,
+                                    RBOOL(node->nd_next->nd_aid),
                                     ID2SYM(node->nd_next->nd_vid),
                                     ID2SYM(node->nd_next->nd_mid),
                                     NEW_CHILD(ast, node->nd_value));
diff --git a/bignum.c b/bignum.c
index 939b33c..9e1ded5 100644
--- a/bignum.c
+++ b/bignum.c
@@ -5471,10 +5471,10 @@ big_op(VALUE x, VALUE y, enum big_op_t op) https://github.com/ruby/ruby/blob/trunk/bignum.c#L5471
     n = FIX2INT(rel);
 
     switch (op) {
-	case big_op_gt: return n >  0 ? Qtrue : Qfalse;
-	case big_op_ge: return n >= 0 ? Qtrue : Qfalse;
-	case big_op_lt: return n <  0 ? Qtrue : Qfalse;
-	case big_op_le: return n <= 0 ? Qtrue : Qfalse;
+	case big_op_gt: return RBOOL(n >  0);
+	case big_op_ge: return RBOOL(n >= 0);
+	case big_op_lt: return RBOOL(n <  0);
+	case big_op_le: return RBOOL(n <= 0);
     }
     return Qundef;
 }
@@ -5518,7 +5518,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/bignum.c#L5518
 rb_big_eq(VALUE x, VALUE y)
 {
     if (FIXNUM_P(y)) {
-	return bignorm(x) == y ? Qtrue : Qfalse;
+	return RBOOL(bignorm(x) == y);
     }
     else if (RB_BIGNUM_TYPE_P(y)) {
     }
diff --git a/compile.c b/compile.c
index 90f0d87..3d1ec62 100644
--- a/compile.c
+++ b/compile.c
@@ -1654,7 +1654,7 @@ access_outer_variables(const rb_iseq_t *iseq, int level, ID id, bool write) https://github.com/ruby/ruby/blob/trunk/compile.c#L1654
             }
         }
         else {
-            rb_id_table_insert(iseq->body->outer_variables, id, write ? Qtrue : Qfalse);
+            rb_id_table_insert(iseq->body->outer_variables, id, RBOOL(write));
         }
 
         iseq = iseq->body->parent_iseq;
@@ -5496,7 +5496,7 @@ setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn, https://github.com/ruby/ruby/blob/trunk/compile.c#L5496
         switch (nd_type(argn)) {
           case NODE_SPLAT: {
             NO_CHECK(COMPILE(args, "args (splat)", argn->nd_head));
-            ADD_INSN1(args, argn, splatarray, dup_rest ? Qtrue : Qfalse);
+            ADD_INSN1(args, argn, splatarray, RBOOL(dup_rest));
             if (flag) *flag |= VM_CALL_ARGS_SPLAT;
             return INT2FIX(1);
           }
diff --git a/dir.c b/dir.c
index 8ac10d2..32bce9f 100644
--- a/dir.c
+++ b/dir.c
@@ -1429,7 +1429,7 @@ with_gvl_gc_for_fd(void *ptr) https://github.com/ruby/ruby/blob/trunk/dir.c#L1429
 {
     int *e = ptr;
 
-    return (void *)(rb_gc_for_fd(*e) ? Qtrue : Qfalse);
+    return (void *)RBOOL(rb_gc_for_fd(*e));
 }
 
 static int
@@ -1438,7 +1438,7 @@ gc_for_fd_with_gvl(int e) https://github.com/ruby/ruby/blob/trunk/dir.c#L1438
     if (vm_initialized)
 	return (int)(VALUE)rb_thread_call_with_gvl(with_gvl_gc_for_fd, &e);
     else
-	return rb_gc_for_fd(e) ? Qtrue : Qfalse;
+	return RBOOL(rb_gc_for_fd(e));
 }
 
 static void *
diff --git a/enumerator.c b/enumerator.c
index 9c91e99..3ada2b0 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -3369,7 +3369,7 @@ rb_arith_seq_new(VALUE obj, VALUE meth, int argc, VALUE const *argv, https://github.com/ruby/ruby/blob/trunk/enumerator.c#L3369
     rb_ivar_set(aseq, id_begin, beg);
     rb_ivar_set(aseq, id_end, end);
     rb_ivar_set(aseq, id_step, step);
-    rb_ivar_set(aseq, id_exclude_end, excl ? Qtrue : Qfalse);
+    rb_ivar_set(aseq, id_exclude_end, RBOOL(excl));
     return aseq;
 }
 
diff --git a/file.c b/file.c
index eb10c54..f5d01fd 100644
--- a/file.c
+++ b/file.c
@@ -5794,11 +5794,11 @@ rb_stat_r(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L5794
 #endif
 #ifdef S_IRUSR
     if (rb_stat_owned(obj))
-	return st->st_mode & S_IRUSR ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IRUSR);
 #endif
 #ifdef S_IRGRP
     if (rb_stat_grpowned(obj))
-	return st->st_mode & S_IRGRP ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IRGRP);
 #endif
 #ifdef S_IROTH
     if (!(st->st_mode & S_IROTH)) return Qfalse;
@@ -5827,11 +5827,11 @@ rb_stat_R(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L5827
 #endif
 #ifdef S_IRUSR
     if (rb_stat_rowned(obj))
-	return st->st_mode & S_IRUSR ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IRUSR);
 #endif
 #ifdef S_IRGRP
     if (rb_group_member(get_stat(obj)->st_gid))
-	return st->st_mode & S_IRGRP ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IRGRP);
 #endif
 #ifdef S_IROTH
     if (!(st->st_mode & S_IROTH)) return Qfalse;
@@ -5887,11 +5887,11 @@ rb_stat_w(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L5887
 #endif
 #ifdef S_IWUSR
     if (rb_stat_owned(obj))
-	return st->st_mode & S_IWUSR ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IWUSR);
 #endif
 #ifdef S_IWGRP
     if (rb_stat_grpowned(obj))
-	return st->st_mode & S_IWGRP ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IWGRP);
 #endif
 #ifdef S_IWOTH
     if (!(st->st_mode & S_IWOTH)) return Qfalse;
@@ -5920,11 +5920,11 @@ rb_stat_W(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L5920
 #endif
 #ifdef S_IWUSR
     if (rb_stat_rowned(obj))
-	return st->st_mode & S_IWUSR ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IWUSR);
 #endif
 #ifdef S_IWGRP
     if (rb_group_member(get_stat(obj)->st_gid))
-	return st->st_mode & S_IWGRP ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IWGRP);
 #endif
 #ifdef S_IWOTH
     if (!(st->st_mode & S_IWOTH)) return Qfalse;
@@ -5979,16 +5979,16 @@ rb_stat_x(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L5979
 
 #ifdef USE_GETEUID
     if (geteuid() == 0) {
-	return st->st_mode & S_IXUGO ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IXUGO);
     }
 #endif
 #ifdef S_IXUSR
     if (rb_stat_owned(obj))
-	return st->st_mode & S_IXUSR ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IXUSR);
 #endif
 #ifdef S_IXGRP
     if (rb_stat_grpowned(obj))
-	return st->st_mode & S_IXGRP ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IXGRP);
 #endif
 #ifdef S_IXOTH
     if (!(st->st_mode & S_IXOTH)) return Qfalse;
@@ -6011,16 +6011,16 @@ rb_stat_X(VALUE obj) https://github.com/ruby/ruby/blob/trunk/file.c#L6011
 
 #ifdef USE_GETEUID
     if (getuid() == 0) {
-	return st->st_mode & S_IXUGO ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IXUGO);
     }
 #endif
 #ifdef S_IXUSR
     if (rb_stat_rowned(obj))
-	return st->st_mode & S_IXUSR ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IXUSR);
 #endif
 #ifdef S_IXGRP
     if (rb_group_member(get_stat(obj)->st_gid))
-	return st->st_mode & S_IXGRP ? Qtrue : Qfalse;
+	return RBOOL(st->st_mode & S_IXGRP);
 #endif
 #ifdef S_IXOTH
     if (!(st->st_mode & S_IXOTH)) return Qfalse;
diff --git a/gc.c b/gc.c
index 2b57241..bae2bdd 100644
--- a/gc.c
+++ b/gc.c
@@ -10445,8 +10445,8 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned https://github.com/ruby/ruby/blob/trunk/gc.c#L10445
         Qnil
     );
 
-    SET(have_finalizer, (flags & GPR_FLAG_HAVE_FINALIZE) ? Qtrue : Qfalse);
-    SET(immediate_sweep, (flags & GPR_FLAG_IMMEDIATE_SWEEP) ? Qtrue : Qfalse);
+    SET(have_finalizer, RBOOL(flags & GPR_FLAG_HAVE_FINALIZE));
+    SET(immediate_sweep, RBOOL(flags & GPR_FLAG_IMMEDIATE_SWEEP));
 
     if (orig_flags == 0) {
         SET(state, gc_mode(objspace) == gc_mode_none ? sym_none :
@@ -12732,7 +12732,7 @@ gc_profile_record_get(VALUE _) https://github.com/ruby/ruby/blob/trunk/gc.c#L12732
 	rb_hash_aset(prof, ID2SYM(rb_intern("REMOVING_OBJECTS")), SIZET2NUM(record->removing_objects));
 	rb_hash_aset(prof, ID2SYM(rb_intern("EMPTY_OBJECTS")), SIZET2NUM(record->empty_objects));
 
-	rb_hash_aset(prof, ID2SYM(rb_intern("HAVE_FINALIZE")), (record->flags & GPR_FLAG_HAVE_FINALIZE) ? Qtrue : Qfalse);
+	rb_hash_aset(prof, ID2SYM(rb_intern("HAVE_FINALIZE")), RBOOL(record->flags & GPR_FLAG_HAVE_FINALIZE));
 #endif
 
 #if RGENGC_PROFILE > 0
@@ -13553,7 +13553,7 @@ Init_GC(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L13553
     rb_mGC = rb_define_module("GC");
 
     gc_constants = rb_hash_new();
-    rb_hash_aset(gc_constants, ID2SYM(rb_intern("DEBUG")), GC_DEBUG ? Qtrue : Qfalse);
+    rb_hash_aset(gc_constants, ID2SYM(rb_intern("DEBUG")), RBOOL(GC_DEBUG));
     rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(sizeof(RVALUE)));
     rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_OBJ_LIMIT")), SIZET2NUM(HEAP_PAGE_OBJ_LIMIT));
     rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_BITMAP_SIZE")), SIZET2NUM(HEAP_PAGE_BITMAP_SIZE));
diff --git a/iseq.c b/iseq.c
index 3dd (... truncated)

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

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