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

ruby-changes:62217

From: Koichi <ko1@a...>
Date: Wed, 15 Jul 2020 13:37:02 +0900 (JST)
Subject: [ruby-changes:62217] c25d249e63 (master): RBasci::flags (VALUE) doesn't match int.

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

From c25d249e63e74499a017330e4281d934911365d4 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Wed, 15 Jul 2020 13:34:54 +0900
Subject: RBasci::flags (VALUE) doesn't match int.

The type of RBasic::flags is VALUE, and INT2FIX(flags) does not
make sense. Use correct type to represent.

diff --git a/spec/ruby/optional/capi/ext/rbasic_spec.c b/spec/ruby/optional/capi/ext/rbasic_spec.c
index c08c821..05eca76 100644
--- a/spec/ruby/optional/capi/ext/rbasic_spec.c
+++ b/spec/ruby/optional/capi/ext/rbasic_spec.c
@@ -7,23 +7,34 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/rbasic_spec.c#L7
 
 static const VALUE VISIBLE_BITS = FL_TAINT | FL_FREEZE | ~(FL_USER0 - 1);
 
+#if SIZEOF_VALUE == SIZEOF_LONG
+#define VALUE2NUM(v) ULONG2NUM(v)
+#define NUM2VALUE(n) NUM2ULONG(n)
+#elif SIZEOF_VALUE == SIZEOF_LONG_LONG
+#define VALUE2NUM(v) ULL2NUM(v)
+#define NUM2VALUE(n) NUM2ULL(n)
+#else
+#error "unsupported"
+#endif
+
+
 VALUE rbasic_spec_taint_flag(VALUE self) {
-  return INT2FIX(RUBY_FL_TAINT);
+  return VALUE2NUM(RUBY_FL_TAINT);
 }
 
 VALUE rbasic_spec_freeze_flag(VALUE self) {
-  return INT2FIX(RUBY_FL_FREEZE);
+  return VALUE2NUM(RUBY_FL_FREEZE);
 }
 
 static VALUE spec_get_flags(const struct RBasic *b) {
   VALUE flags = b->flags & VISIBLE_BITS;
-  return INT2FIX(flags);
+  return VALUE2NUM(flags);
 }
 
 static VALUE spec_set_flags(struct RBasic *b, VALUE flags) {
   flags &= VISIBLE_BITS;
   b->flags = (b->flags & ~VISIBLE_BITS) | flags;
-  return INT2FIX(flags);
+  return VALUE2NUM(flags);
 }
 
 VALUE rbasic_spec_get_flags(VALUE self, VALUE val) {
@@ -31,7 +42,7 @@ VALUE rbasic_spec_get_flags(VALUE self, VALUE val) { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/rbasic_spec.c#L42
 }
 
 VALUE rbasic_spec_set_flags(VALUE self, VALUE val, VALUE flags) {
-  return spec_set_flags(RBASIC(val), FIX2INT(flags));
+  return spec_set_flags(RBASIC(val), NUM2VALUE(flags));
 }
 
 VALUE rbasic_spec_copy_flags(VALUE self, VALUE to, VALUE from) {
@@ -47,7 +58,7 @@ VALUE rbasic_rdata_spec_get_flags(VALUE self, VALUE structure) { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/rbasic_spec.c#L58
 }
 
 VALUE rbasic_rdata_spec_set_flags(VALUE self, VALUE structure, VALUE flags) {
-  return spec_set_flags(&RDATA(structure)->basic, FIX2INT(flags));
+  return spec_set_flags(&RDATA(structure)->basic, NUM2VALUE(flags));
 }
 
 VALUE rbasic_rdata_spec_copy_flags(VALUE self, VALUE to, VALUE from) {
-- 
cgit v0.10.2


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

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