summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-27 15:35:23 (GMT)
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-27 15:35:23 (GMT)
commitf949a95dab55dc6bf0a0f98aecbbda699cb30397 (patch)
tree448301eb89242bbb448363b98f391615cb4fcccd /numeric.c
parentc71e02bd07b1ae7211ee2cafad39e9b13f9d33d3 (diff)
{Fixnum,Bignum}#^ is unified into Integer.
* numeric.c (int_xor): {Fixnum,Bignum}#^ is unified into Integer. * bignum.c (rb_big_xor): Don't define Bignum#^. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/numeric.c b/numeric.c
index 7dd5371..8335a2c 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);