aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-30 03:08:53 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-30 03:08:53 +0000
commitf4893dea97b755ef34aacaf692b9ac77faa5bfda (patch)
treec9bc8db7ae77b3cc776ff26c7d6fcae20f7b39ca
parent37f5a45a24cce0d6ceb823fd845c66694c0ed389 (diff)
downloadruby-f4893dea97b755ef34aacaf692b9ac77faa5bfda.tar.gz
{Fixnum,Bignum}#& is unified into Integer.
* numeric.c (int_and): {Fixnum,Bignum}#& is unified into Integer. * bignum.c (rb_big_and): Don't define Bignum#|. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--bignum.c8
-rw-r--r--numeric.c18
3 files changed, 22 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 7f3b0920f6..5336bdacd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Apr 30 12:07:42 2016 Tanaka Akira <akr@fsij.org>
+
+ * numeric.c (int_and): {Fixnum,Bignum}#& is unified into
+ Integer.
+
+ * bignum.c (rb_big_and): Don't define Bignum#|.
+
Sat Apr 30 11:56:15 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/thread: removed dummy extension library. thread_sync.c
diff --git a/bignum.c b/bignum.c
index bca8c1ddfe..891c27c77f 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6430,13 +6430,6 @@ bigand_int(VALUE x, long xn, BDIGIT hibitsx, long y)
return bignorm(z);
}
-/*
- * call-seq:
- * big & numeric -> integer
- *
- * Performs bitwise +and+ between _big_ and _numeric_.
- */
-
VALUE
rb_big_and(VALUE x, VALUE y)
{
@@ -6970,7 +6963,6 @@ Init_Bignum(void)
rb_define_method(rb_cBignum, "remainder", rb_big_remainder, 1);
rb_define_method(rb_cBignum, "fdiv", rb_big_fdiv, 1);
rb_define_method(rb_cBignum, "**", rb_big_pow, 1);
- rb_define_method(rb_cBignum, "&", rb_big_and, 1);
rb_define_method(rb_cBignum, "~", rb_big_neg, 0);
rb_define_method(rb_cBignum, "==", rb_big_eq, 1);
diff --git a/numeric.c b/numeric.c
index 95a77d5e4c..948cba9a79 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3889,9 +3889,9 @@ rb_num_coerce_bit(VALUE x, VALUE y, ID func)
}
/*
- * Document-method: Fixnum#&
+ * Document-method: Integer#&
* call-seq:
- * fix & integer -> integer_result
+ * integer & integer -> integer_result
*
* Bitwise AND.
*/
@@ -3912,6 +3912,18 @@ fix_and(VALUE x, VALUE y)
return rb_funcall(x, '&', 1, y);
}
+static VALUE
+int_and(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x)) {
+ return fix_and(x, y);
+ }
+ else if (RB_TYPE_P(x, T_BIGNUM)) {
+ return rb_big_and(x, y);
+ }
+ return Qnil;
+}
+
/*
* Document-method: Integer#|
* call-seq:
@@ -4780,7 +4792,7 @@ Init_Numeric(void)
rb_define_method(rb_cFixnum, "<=", fix_le, 1);
rb_define_method(rb_cFixnum, "~", fix_rev, 0);
- rb_define_method(rb_cFixnum, "&", fix_and, 1);
+ rb_define_method(rb_cInteger, "&", int_and, 1);
rb_define_method(rb_cInteger, "|", int_or, 1);
rb_define_method(rb_cInteger, "^", int_xor, 1);
rb_define_method(rb_cInteger, "[]", int_aref, 1);