summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--bignum.c7
-rw-r--r--numeric.c18
3 files changed, 22 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 26f6a7b105..b404c82d18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Apr 28 00:27:55 2016 Tanaka Akira <akr@fsij.org>
+
+ * numeric.c (int_xor): {Fixnum,Bignum}#^ is unified into
+ Integer.
+
+ * bignum.c (rb_big_xor): Don't define Bignum#^.
+
Wed Apr 27 20:53:59 2016 Tanaka Akira <akr@fsij.org>
* numeric.c (int_aref): {Fixnum,Bignum}#[] is unified into
diff --git a/bignum.c b/bignum.c
index 7cdc863d84..35d2fba665 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6656,12 +6656,6 @@ bigxor_int(VALUE x, long xn, BDIGIT hibitsx, long y)
RB_GC_GUARD(x);
return bignorm(z);
}
-/*
- * call-seq:
- * big ^ numeric -> integer
- *
- * Performs bitwise +exclusive or+ between _big_ and _numeric_.
- */
VALUE
rb_big_xor(VALUE x, VALUE y)
@@ -6985,7 +6979,6 @@ Init_Bignum(void)
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_or, 1);
- rb_define_method(rb_cBignum, "^", rb_big_xor, 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 7dd53713d9..8335a2c45c 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3937,9 +3937,9 @@ fix_or(VALUE x, VALUE y)
}
/*
- * Document-method: Fixnum#^
+ * Document-method: Integer#^
* call-seq:
- * fix ^ integer -> integer_result
+ * integer ^ integer -> integer_result
*
* Bitwise EXCLUSIVE OR.
*/
@@ -3960,6 +3960,18 @@ fix_xor(VALUE x, VALUE y)
return rb_funcall(x, '^', 1, y);
}
+static VALUE
+int_xor(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x)) {
+ return fix_xor(x, y);
+ }
+ else if (RB_TYPE_P(x, T_BIGNUM)) {
+ return rb_big_xor(x, y);
+ }
+ return Qnil;
+}
+
/*
* Document-method: Integer#<<
* call-seq:
@@ -4758,7 +4770,7 @@ Init_Numeric(void)
rb_define_method(rb_cFixnum, "~", fix_rev, 0);
rb_define_method(rb_cFixnum, "&", fix_and, 1);
rb_define_method(rb_cFixnum, "|", fix_or, 1);
- rb_define_method(rb_cFixnum, "^", fix_xor, 1);
+ rb_define_method(rb_cInteger, "^", int_xor, 1);
rb_define_method(rb_cInteger, "[]", int_aref, 1);
rb_define_method(rb_cInteger, "<<", rb_int_lshift, 1);