mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
FL_USER flags on ohter than T_DATA are reserved [Misc #18059]
This commit is contained in:
parent
9151ed2fb2
commit
69ce154d6e
1 changed files with 15 additions and 13 deletions
|
@ -6,9 +6,11 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FL_SHAREABLE
|
#ifndef FL_SHAREABLE
|
||||||
static const VALUE VISIBLE_BITS = FL_TAINT | FL_FREEZE | ~(FL_USER0 - 1);
|
static const VALUE VISIBLE_BITS = FL_TAINT | FL_FREEZE;
|
||||||
|
static const VALUE DATA_VISIBLE_BITS = FL_TAINT | FL_FREEZE | ~(FL_USER0 - 1);
|
||||||
#else
|
#else
|
||||||
static const VALUE VISIBLE_BITS = FL_FREEZE | ~(FL_USER0 - 1);
|
static const VALUE VISIBLE_BITS = FL_FREEZE;
|
||||||
|
static const VALUE DATA_VISIBLE_BITS = FL_FREEZE | ~(FL_USER0 - 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SIZEOF_VALUE == SIZEOF_LONG
|
#if SIZEOF_VALUE == SIZEOF_LONG
|
||||||
|
@ -32,27 +34,27 @@ VALUE rbasic_spec_freeze_flag(VALUE self) {
|
||||||
return VALUE2NUM(RUBY_FL_FREEZE);
|
return VALUE2NUM(RUBY_FL_FREEZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE spec_get_flags(const struct RBasic *b) {
|
static VALUE spec_get_flags(const struct RBasic *b, VALUE visible_bits) {
|
||||||
VALUE flags = b->flags & VISIBLE_BITS;
|
VALUE flags = b->flags & visible_bits;
|
||||||
return VALUE2NUM(flags);
|
return VALUE2NUM(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE spec_set_flags(struct RBasic *b, VALUE flags) {
|
static VALUE spec_set_flags(struct RBasic *b, VALUE flags, VALUE visible_bits) {
|
||||||
flags &= VISIBLE_BITS;
|
flags &= visible_bits;
|
||||||
b->flags = (b->flags & ~VISIBLE_BITS) | flags;
|
b->flags = (b->flags & ~visible_bits) | flags;
|
||||||
return VALUE2NUM(flags);
|
return VALUE2NUM(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rbasic_spec_get_flags(VALUE self, VALUE val) {
|
VALUE rbasic_spec_get_flags(VALUE self, VALUE val) {
|
||||||
return spec_get_flags(RBASIC(val));
|
return spec_get_flags(RBASIC(val), VISIBLE_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rbasic_spec_set_flags(VALUE self, VALUE val, VALUE flags) {
|
VALUE rbasic_spec_set_flags(VALUE self, VALUE val, VALUE flags) {
|
||||||
return spec_set_flags(RBASIC(val), NUM2VALUE(flags));
|
return spec_set_flags(RBASIC(val), NUM2VALUE(flags), VISIBLE_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rbasic_spec_copy_flags(VALUE self, VALUE to, VALUE from) {
|
VALUE rbasic_spec_copy_flags(VALUE self, VALUE to, VALUE from) {
|
||||||
return spec_set_flags(RBASIC(to), RBASIC(from)->flags);
|
return spec_set_flags(RBASIC(to), RBASIC(from)->flags, VISIBLE_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rbasic_spec_get_klass(VALUE self, VALUE val) {
|
VALUE rbasic_spec_get_klass(VALUE self, VALUE val) {
|
||||||
|
@ -60,15 +62,15 @@ VALUE rbasic_spec_get_klass(VALUE self, VALUE val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rbasic_rdata_spec_get_flags(VALUE self, VALUE structure) {
|
VALUE rbasic_rdata_spec_get_flags(VALUE self, VALUE structure) {
|
||||||
return spec_get_flags(&RDATA(structure)->basic);
|
return spec_get_flags(&RDATA(structure)->basic, DATA_VISIBLE_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rbasic_rdata_spec_set_flags(VALUE self, VALUE structure, VALUE flags) {
|
VALUE rbasic_rdata_spec_set_flags(VALUE self, VALUE structure, VALUE flags) {
|
||||||
return spec_set_flags(&RDATA(structure)->basic, NUM2VALUE(flags));
|
return spec_set_flags(&RDATA(structure)->basic, NUM2VALUE(flags), DATA_VISIBLE_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rbasic_rdata_spec_copy_flags(VALUE self, VALUE to, VALUE from) {
|
VALUE rbasic_rdata_spec_copy_flags(VALUE self, VALUE to, VALUE from) {
|
||||||
return spec_set_flags(&RDATA(to)->basic, RDATA(from)->basic.flags);
|
return spec_set_flags(&RDATA(to)->basic, RDATA(from)->basic.flags, DATA_VISIBLE_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE rbasic_rdata_spec_get_klass(VALUE self, VALUE structure) {
|
VALUE rbasic_rdata_spec_get_klass(VALUE self, VALUE structure) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue