1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Replace RBOOL macro

This commit is contained in:
S-H-GAMELINKS 2021-08-31 20:30:35 +09:00 committed by Nobuyoshi Nakada
parent 8f752c95d2
commit bdd6d8746f
Notes: git 2021-09-05 23:01:54 +09:00
15 changed files with 43 additions and 43 deletions

4
ast.c
View file

@ -366,7 +366,7 @@ node_children(rb_ast_t *ast, const NODE *node)
case NODE_WHILE: case NODE_WHILE:
case NODE_UNTIL: case NODE_UNTIL:
return rb_ary_push(rb_ary_new_from_node_args(ast, 2, node->nd_cond, node->nd_body), 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_ITER:
case NODE_FOR: case NODE_FOR:
return rb_ary_new_from_node_args(ast, 2, node->nd_iter, node->nd_body); 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)
NEW_CHILD(ast, node->nd_args->nd_body)); NEW_CHILD(ast, node->nd_args->nd_body));
case NODE_OP_ASGN2: case NODE_OP_ASGN2:
return rb_ary_new_from_args(5, NEW_CHILD(ast, node->nd_recv), 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_vid),
ID2SYM(node->nd_next->nd_mid), ID2SYM(node->nd_next->nd_mid),
NEW_CHILD(ast, node->nd_value)); NEW_CHILD(ast, node->nd_value));

View file

@ -5471,10 +5471,10 @@ big_op(VALUE x, VALUE y, enum big_op_t op)
n = FIX2INT(rel); n = FIX2INT(rel);
switch (op) { switch (op) {
case big_op_gt: return n > 0 ? Qtrue : Qfalse; case big_op_gt: return RBOOL(n > 0);
case big_op_ge: return n >= 0 ? Qtrue : Qfalse; case big_op_ge: return RBOOL(n >= 0);
case big_op_lt: return n < 0 ? Qtrue : Qfalse; case big_op_lt: return RBOOL(n < 0);
case big_op_le: return n <= 0 ? Qtrue : Qfalse; case big_op_le: return RBOOL(n <= 0);
} }
return Qundef; return Qundef;
} }
@ -5518,7 +5518,7 @@ VALUE
rb_big_eq(VALUE x, VALUE y) rb_big_eq(VALUE x, VALUE y)
{ {
if (FIXNUM_P(y)) { if (FIXNUM_P(y)) {
return bignorm(x) == y ? Qtrue : Qfalse; return RBOOL(bignorm(x) == y);
} }
else if (RB_BIGNUM_TYPE_P(y)) { else if (RB_BIGNUM_TYPE_P(y)) {
} }

View file

@ -1654,7 +1654,7 @@ access_outer_variables(const rb_iseq_t *iseq, int level, ID id, bool write)
} }
} }
else { 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; iseq = iseq->body->parent_iseq;
@ -5496,7 +5496,7 @@ setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
switch (nd_type(argn)) { switch (nd_type(argn)) {
case NODE_SPLAT: { case NODE_SPLAT: {
NO_CHECK(COMPILE(args, "args (splat)", argn->nd_head)); 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; if (flag) *flag |= VM_CALL_ARGS_SPLAT;
return INT2FIX(1); return INT2FIX(1);
} }

4
dir.c
View file

@ -1429,7 +1429,7 @@ with_gvl_gc_for_fd(void *ptr)
{ {
int *e = ptr; int *e = ptr;
return (void *)(rb_gc_for_fd(*e) ? Qtrue : Qfalse); return (void *)RBOOL(rb_gc_for_fd(*e));
} }
static int static int
@ -1438,7 +1438,7 @@ gc_for_fd_with_gvl(int e)
if (vm_initialized) if (vm_initialized)
return (int)(VALUE)rb_thread_call_with_gvl(with_gvl_gc_for_fd, &e); return (int)(VALUE)rb_thread_call_with_gvl(with_gvl_gc_for_fd, &e);
else else
return rb_gc_for_fd(e) ? Qtrue : Qfalse; return RBOOL(rb_gc_for_fd(e));
} }
static void * static void *

View file

@ -3369,7 +3369,7 @@ rb_arith_seq_new(VALUE obj, VALUE meth, int argc, VALUE const *argv,
rb_ivar_set(aseq, id_begin, beg); rb_ivar_set(aseq, id_begin, beg);
rb_ivar_set(aseq, id_end, end); rb_ivar_set(aseq, id_end, end);
rb_ivar_set(aseq, id_step, step); 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; return aseq;
} }

28
file.c
View file

@ -5794,11 +5794,11 @@ rb_stat_r(VALUE obj)
#endif #endif
#ifdef S_IRUSR #ifdef S_IRUSR
if (rb_stat_owned(obj)) if (rb_stat_owned(obj))
return st->st_mode & S_IRUSR ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IRUSR);
#endif #endif
#ifdef S_IRGRP #ifdef S_IRGRP
if (rb_stat_grpowned(obj)) if (rb_stat_grpowned(obj))
return st->st_mode & S_IRGRP ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IRGRP);
#endif #endif
#ifdef S_IROTH #ifdef S_IROTH
if (!(st->st_mode & S_IROTH)) return Qfalse; if (!(st->st_mode & S_IROTH)) return Qfalse;
@ -5827,11 +5827,11 @@ rb_stat_R(VALUE obj)
#endif #endif
#ifdef S_IRUSR #ifdef S_IRUSR
if (rb_stat_rowned(obj)) if (rb_stat_rowned(obj))
return st->st_mode & S_IRUSR ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IRUSR);
#endif #endif
#ifdef S_IRGRP #ifdef S_IRGRP
if (rb_group_member(get_stat(obj)->st_gid)) 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 #endif
#ifdef S_IROTH #ifdef S_IROTH
if (!(st->st_mode & S_IROTH)) return Qfalse; if (!(st->st_mode & S_IROTH)) return Qfalse;
@ -5887,11 +5887,11 @@ rb_stat_w(VALUE obj)
#endif #endif
#ifdef S_IWUSR #ifdef S_IWUSR
if (rb_stat_owned(obj)) if (rb_stat_owned(obj))
return st->st_mode & S_IWUSR ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IWUSR);
#endif #endif
#ifdef S_IWGRP #ifdef S_IWGRP
if (rb_stat_grpowned(obj)) if (rb_stat_grpowned(obj))
return st->st_mode & S_IWGRP ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IWGRP);
#endif #endif
#ifdef S_IWOTH #ifdef S_IWOTH
if (!(st->st_mode & S_IWOTH)) return Qfalse; if (!(st->st_mode & S_IWOTH)) return Qfalse;
@ -5920,11 +5920,11 @@ rb_stat_W(VALUE obj)
#endif #endif
#ifdef S_IWUSR #ifdef S_IWUSR
if (rb_stat_rowned(obj)) if (rb_stat_rowned(obj))
return st->st_mode & S_IWUSR ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IWUSR);
#endif #endif
#ifdef S_IWGRP #ifdef S_IWGRP
if (rb_group_member(get_stat(obj)->st_gid)) 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 #endif
#ifdef S_IWOTH #ifdef S_IWOTH
if (!(st->st_mode & S_IWOTH)) return Qfalse; if (!(st->st_mode & S_IWOTH)) return Qfalse;
@ -5979,16 +5979,16 @@ rb_stat_x(VALUE obj)
#ifdef USE_GETEUID #ifdef USE_GETEUID
if (geteuid() == 0) { if (geteuid() == 0) {
return st->st_mode & S_IXUGO ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IXUGO);
} }
#endif #endif
#ifdef S_IXUSR #ifdef S_IXUSR
if (rb_stat_owned(obj)) if (rb_stat_owned(obj))
return st->st_mode & S_IXUSR ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IXUSR);
#endif #endif
#ifdef S_IXGRP #ifdef S_IXGRP
if (rb_stat_grpowned(obj)) if (rb_stat_grpowned(obj))
return st->st_mode & S_IXGRP ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IXGRP);
#endif #endif
#ifdef S_IXOTH #ifdef S_IXOTH
if (!(st->st_mode & S_IXOTH)) return Qfalse; if (!(st->st_mode & S_IXOTH)) return Qfalse;
@ -6011,16 +6011,16 @@ rb_stat_X(VALUE obj)
#ifdef USE_GETEUID #ifdef USE_GETEUID
if (getuid() == 0) { if (getuid() == 0) {
return st->st_mode & S_IXUGO ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IXUGO);
} }
#endif #endif
#ifdef S_IXUSR #ifdef S_IXUSR
if (rb_stat_rowned(obj)) if (rb_stat_rowned(obj))
return st->st_mode & S_IXUSR ? Qtrue : Qfalse; return RBOOL(st->st_mode & S_IXUSR);
#endif #endif
#ifdef S_IXGRP #ifdef S_IXGRP
if (rb_group_member(get_stat(obj)->st_gid)) 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 #endif
#ifdef S_IXOTH #ifdef S_IXOTH
if (!(st->st_mode & S_IXOTH)) return Qfalse; if (!(st->st_mode & S_IXOTH)) return Qfalse;

8
gc.c
View file

@ -10445,8 +10445,8 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
Qnil Qnil
); );
SET(have_finalizer, (flags & GPR_FLAG_HAVE_FINALIZE) ? Qtrue : Qfalse); SET(have_finalizer, RBOOL(flags & GPR_FLAG_HAVE_FINALIZE));
SET(immediate_sweep, (flags & GPR_FLAG_IMMEDIATE_SWEEP) ? Qtrue : Qfalse); SET(immediate_sweep, RBOOL(flags & GPR_FLAG_IMMEDIATE_SWEEP));
if (orig_flags == 0) { if (orig_flags == 0) {
SET(state, gc_mode(objspace) == gc_mode_none ? sym_none : SET(state, gc_mode(objspace) == gc_mode_none ? sym_none :
@ -12732,7 +12732,7 @@ gc_profile_record_get(VALUE _)
rb_hash_aset(prof, ID2SYM(rb_intern("REMOVING_OBJECTS")), SIZET2NUM(record->removing_objects)); 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("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 #endif
#if RGENGC_PROFILE > 0 #if RGENGC_PROFILE > 0
@ -13553,7 +13553,7 @@ Init_GC(void)
rb_mGC = rb_define_module("GC"); rb_mGC = rb_define_module("GC");
gc_constants = rb_hash_new(); 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("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_OBJ_LIMIT")), SIZET2NUM(HEAP_PAGE_OBJ_LIMIT));
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_BITMAP_SIZE")), SIZET2NUM(HEAP_PAGE_BITMAP_SIZE)); rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_BITMAP_SIZE")), SIZET2NUM(HEAP_PAGE_BITMAP_SIZE));

2
iseq.c
View file

@ -784,7 +784,7 @@ make_compile_option_value(rb_compile_option_t *option)
{ {
VALUE opt = rb_hash_new_with_size(11); VALUE opt = rb_hash_new_with_size(11);
#define SET_COMPILE_OPTION(o, h, mem) \ #define SET_COMPILE_OPTION(o, h, mem) \
rb_hash_aset((h), ID2SYM(rb_intern(#mem)), (o)->mem ? Qtrue : Qfalse) rb_hash_aset((h), ID2SYM(rb_intern(#mem)), RBOOL((o)->mem))
#define SET_COMPILE_OPTION_NUM(o, h, mem) \ #define SET_COMPILE_OPTION_NUM(o, h, mem) \
rb_hash_aset((h), ID2SYM(rb_intern(#mem)), INT2NUM((o)->mem)) rb_hash_aset((h), ID2SYM(rb_intern(#mem)), INT2NUM((o)->mem))
{ {

View file

@ -282,7 +282,7 @@ class Float
# #
def zero? def zero?
Primitive.attr! 'inline' Primitive.attr! 'inline'
Primitive.cexpr! 'FLOAT_ZERO_P(self) ? Qtrue : Qfalse' Primitive.cexpr! 'RBOOL(FLOAT_ZERO_P(self))'
end end
# #
@ -293,7 +293,7 @@ class Float
# #
def positive? def positive?
Primitive.attr! 'inline' Primitive.attr! 'inline'
Primitive.cexpr! 'RFLOAT_VALUE(self) > 0.0 ? Qtrue : Qfalse' Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) > 0.0)'
end end
# #
@ -304,6 +304,6 @@ class Float
# #
def negative? def negative?
Primitive.attr! 'inline' Primitive.attr! 'inline'
Primitive.cexpr! 'RFLOAT_VALUE(self) < 0.0 ? Qtrue : Qfalse' Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) < 0.0)'
end end
end end

View file

@ -8108,7 +8108,7 @@ parser_set_compile_option_flag(struct parser_params *p, const char *name, const
if (!p->compile_option) if (!p->compile_option)
p->compile_option = rb_obj_hide(rb_ident_hash_new()); p->compile_option = rb_obj_hide(rb_ident_hash_new());
rb_hash_aset(p->compile_option, ID2SYM(rb_intern(name)), rb_hash_aset(p->compile_option, ID2SYM(rb_intern(name)),
(b ? Qtrue : Qfalse)); RBOOL(b));
} }
static void static void
@ -13231,7 +13231,7 @@ ripper_error_p(VALUE vparser)
struct parser_params *p; struct parser_params *p;
TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p); TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
return p->error_p ? Qtrue : Qfalse; return RBOOL(p->error_p);
} }
#endif #endif
@ -13247,7 +13247,7 @@ rb_parser_end_seen_p(VALUE vparser)
struct parser_params *p; struct parser_params *p;
TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p); TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
return p->ruby__end__seen ? Qtrue : Qfalse; return RBOOL(p->ruby__end__seen);
} }
/* /*
@ -13278,7 +13278,7 @@ rb_parser_get_yydebug(VALUE self)
struct parser_params *p; struct parser_params *p;
TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p); TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
return p->debug ? Qtrue : Qfalse; return RBOOL(p->debug);
} }
#endif #endif

View file

@ -1025,7 +1025,7 @@ pst_success_p(VALUE st)
if (!WIFEXITED(status)) if (!WIFEXITED(status))
return Qnil; return Qnil;
return WEXITSTATUS(status) == EXIT_SUCCESS ? Qtrue : Qfalse; return RBOOL(WEXITSTATUS(status) == EXIT_SUCCESS);
} }

View file

@ -768,7 +768,7 @@ class Ractor
# See also the "Shareable and unshareable objects" section in the Ractor class docs. # See also the "Shareable and unshareable objects" section in the Ractor class docs.
def self.shareable? obj def self.shareable? obj
__builtin_cexpr! %q{ __builtin_cexpr! %q{
rb_ractor_shareable_p(obj) ? Qtrue : Qfalse; RBOOL(rb_ractor_shareable_p(obj));
} }
end end

2
ruby.c
View file

@ -1926,7 +1926,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
VALUE option = rb_hash_new(); VALUE option = rb_hash_new();
#define SET_COMPILE_OPTION(h, o, name) \ #define SET_COMPILE_OPTION(h, o, name) \
rb_hash_aset((h), ID2SYM(rb_intern_const(#name)), \ rb_hash_aset((h), ID2SYM(rb_intern_const(#name)), \
(FEATURE_SET_P(o->features, FEATURE_BIT(name)) ? Qtrue : Qfalse)); RBOOL(FEATURE_SET_P(o->features, FEATURE_BIT(name))));
SET_COMPILE_OPTION(option, opt, frozen_string_literal); SET_COMPILE_OPTION(option, opt, frozen_string_literal);
SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal); SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
rb_funcallv(rb_cISeq, rb_intern_const("compile_option="), 1, &option); rb_funcallv(rb_cISeq, rb_intern_const("compile_option="), 1, &option);

2
time.c
View file

@ -4460,7 +4460,7 @@ time_wday(VALUE time)
} }
#define wday_p(n) {\ #define wday_p(n) {\
return (time_wday(time) == INT2FIX(n)) ? Qtrue : Qfalse; \ return RBOOL(time_wday(time) == INT2FIX(n)); \
} }
/* /*

View file

@ -2079,7 +2079,7 @@ make_econv_exception(rb_econv_t *ec)
exc = rb_exc_new3(rb_eInvalidByteSequenceError, mesg); exc = rb_exc_new3(rb_eInvalidByteSequenceError, mesg);
rb_ivar_set(exc, id_error_bytes, bytes); rb_ivar_set(exc, id_error_bytes, bytes);
rb_ivar_set(exc, id_readagain_bytes, bytes2); rb_ivar_set(exc, id_readagain_bytes, bytes2);
rb_ivar_set(exc, id_incomplete_input, ec->last_error.result == econv_incomplete_input ? Qtrue : Qfalse); rb_ivar_set(exc, id_incomplete_input, RBOOL(ec->last_error.result == econv_incomplete_input));
goto set_encs; goto set_encs;
} }
if (ec->last_error.result == econv_undefined_conversion) { if (ec->last_error.result == econv_undefined_conversion) {