зеркало из https://github.com/github/ruby.git
Replace RBOOL macro
This commit is contained in:
Родитель
8f752c95d2
Коммит
bdd6d8746f
4
ast.c
4
ast.c
|
@ -366,7 +366,7 @@ node_children(rb_ast_t *ast, const NODE *node)
|
|||
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)
|
|||
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));
|
||||
|
|
10
bignum.c
10
bignum.c
|
@ -5471,10 +5471,10 @@ big_op(VALUE x, VALUE y, enum big_op_t op)
|
|||
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
|
|||
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)) {
|
||||
}
|
||||
|
|
|
@ -1654,7 +1654,7 @@ access_outer_variables(const rb_iseq_t *iseq, int level, ID id, bool write)
|
|||
}
|
||||
}
|
||||
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,
|
|||
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);
|
||||
}
|
||||
|
|
4
dir.c
4
dir.c
|
@ -1429,7 +1429,7 @@ with_gvl_gc_for_fd(void *ptr)
|
|||
{
|
||||
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)
|
|||
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 *
|
||||
|
|
|
@ -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_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;
|
||||
}
|
||||
|
||||
|
|
28
file.c
28
file.c
|
@ -5794,11 +5794,11 @@ rb_stat_r(VALUE obj)
|
|||
#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)
|
|||
#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)
|
|||
#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)
|
|||
#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)
|
|||
|
||||
#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)
|
|||
|
||||
#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;
|
||||
|
|
8
gc.c
8
gc.c
|
@ -10445,8 +10445,8 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
|
|||
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 _)
|
|||
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)
|
|||
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));
|
||||
|
|
2
iseq.c
2
iseq.c
|
@ -784,7 +784,7 @@ make_compile_option_value(rb_compile_option_t *option)
|
|||
{
|
||||
VALUE opt = rb_hash_new_with_size(11);
|
||||
#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) \
|
||||
rb_hash_aset((h), ID2SYM(rb_intern(#mem)), INT2NUM((o)->mem))
|
||||
{
|
||||
|
|
|
@ -282,7 +282,7 @@ class Float
|
|||
#
|
||||
def zero?
|
||||
Primitive.attr! 'inline'
|
||||
Primitive.cexpr! 'FLOAT_ZERO_P(self) ? Qtrue : Qfalse'
|
||||
Primitive.cexpr! 'RBOOL(FLOAT_ZERO_P(self))'
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -293,7 +293,7 @@ class Float
|
|||
#
|
||||
def positive?
|
||||
Primitive.attr! 'inline'
|
||||
Primitive.cexpr! 'RFLOAT_VALUE(self) > 0.0 ? Qtrue : Qfalse'
|
||||
Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) > 0.0)'
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -304,6 +304,6 @@ class Float
|
|||
#
|
||||
def negative?
|
||||
Primitive.attr! 'inline'
|
||||
Primitive.cexpr! 'RFLOAT_VALUE(self) < 0.0 ? Qtrue : Qfalse'
|
||||
Primitive.cexpr! 'RBOOL(RFLOAT_VALUE(self) < 0.0)'
|
||||
end
|
||||
end
|
||||
|
|
8
parse.y
8
parse.y
|
@ -8108,7 +8108,7 @@ parser_set_compile_option_flag(struct parser_params *p, const char *name, const
|
|||
if (!p->compile_option)
|
||||
p->compile_option = rb_obj_hide(rb_ident_hash_new());
|
||||
rb_hash_aset(p->compile_option, ID2SYM(rb_intern(name)),
|
||||
(b ? Qtrue : Qfalse));
|
||||
RBOOL(b));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -13231,7 +13231,7 @@ ripper_error_p(VALUE vparser)
|
|||
struct parser_params *p;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct parser_params, &parser_data_type, p);
|
||||
return p->error_p ? Qtrue : Qfalse;
|
||||
return RBOOL(p->error_p);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -13247,7 +13247,7 @@ rb_parser_end_seen_p(VALUE vparser)
|
|||
struct parser_params *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;
|
||||
|
||||
TypedData_Get_Struct(self, struct parser_params, &parser_data_type, p);
|
||||
return p->debug ? Qtrue : Qfalse;
|
||||
return RBOOL(p->debug);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1025,7 +1025,7 @@ pst_success_p(VALUE st)
|
|||
|
||||
if (!WIFEXITED(status))
|
||||
return Qnil;
|
||||
return WEXITSTATUS(status) == EXIT_SUCCESS ? Qtrue : Qfalse;
|
||||
return RBOOL(WEXITSTATUS(status) == EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -768,7 +768,7 @@ class Ractor
|
|||
# See also the "Shareable and unshareable objects" section in the Ractor class docs.
|
||||
def self.shareable? obj
|
||||
__builtin_cexpr! %q{
|
||||
rb_ractor_shareable_p(obj) ? Qtrue : Qfalse;
|
||||
RBOOL(rb_ractor_shareable_p(obj));
|
||||
}
|
||||
end
|
||||
|
||||
|
|
2
ruby.c
2
ruby.c
|
@ -1926,7 +1926,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
|||
VALUE option = rb_hash_new();
|
||||
#define SET_COMPILE_OPTION(h, o, 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, debug_frozen_string_literal);
|
||||
rb_funcallv(rb_cISeq, rb_intern_const("compile_option="), 1, &option);
|
||||
|
|
2
time.c
2
time.c
|
@ -4460,7 +4460,7 @@ time_wday(VALUE time)
|
|||
}
|
||||
|
||||
#define wday_p(n) {\
|
||||
return (time_wday(time) == INT2FIX(n)) ? Qtrue : Qfalse; \
|
||||
return RBOOL(time_wday(time) == INT2FIX(n)); \
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -2079,7 +2079,7 @@ make_econv_exception(rb_econv_t *ec)
|
|||
exc = rb_exc_new3(rb_eInvalidByteSequenceError, mesg);
|
||||
rb_ivar_set(exc, id_error_bytes, bytes);
|
||||
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;
|
||||
}
|
||||
if (ec->last_error.result == econv_undefined_conversion) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче