Permalink
Browse files

move the implementation about #hash from Array to NSArray, in order t…

…o use its methods with Array/NSArray
  • Loading branch information...
1 parent 18039d9 commit fdc829b74a74f5233a328e5faafebb5e94e40713 @Watson1978 Watson1978 committed Sep 25, 2012
Showing with 3 additions and 2 deletions.
  1. +1 −0 NSArray.m
  2. +1 −2 array.c
  3. +1 −0 array.h
View
@@ -1150,6 +1150,7 @@
rb_objc_define_method(rb_cArray, "&", rary_and, 1);
rb_objc_define_method(rb_cArray, "|", rary_or, 1);
rb_objc_define_method(rb_cArray, "join", rary_join, -1);
+ rb_objc_define_method(rb_cArray, "hash", rary_hash, 0);
rb_objc_define_method(rb_cArray, "zip", rary_zip, -1);
rb_objc_define_method(rb_cArray, "transpose", rary_transpose, 0);
rb_objc_define_method(rb_cArray, "fill", rary_fill, -1);
View
@@ -2596,7 +2596,7 @@ rary_eql_fast(rb_ary_t *ary1, rb_ary_t *ary2)
* will have the same hash code (and will compare using <code>eql?</code>).
*/
-static VALUE
+VALUE
rary_hash(VALUE ary, SEL sel)
{
return LONG2FIX(rb_ary_hash(ary));
@@ -3813,7 +3813,6 @@ Init_Array(void)
rb_objc_define_method(rb_cRubyArray, "inspect", rary_inspect, 0);
rb_objc_define_method(rb_cRubyArray, "==", rary_equal, 1);
rb_objc_define_method(rb_cRubyArray, "eql?", rary_eql, 1);
- rb_objc_define_method(rb_cRubyArray, "hash", rary_hash, 0);
rb_objc_define_method(rb_cRubyArray, "[]", rary_aref, -1);
rb_objc_define_method(rb_cRubyArray, "[]=", rary_aset, -1);
rb_objc_define_method(rb_cRubyArray, "at", rary_at, 1);
View
@@ -160,6 +160,7 @@ bool rary_eql_fast(rb_ary_t *ary1, rb_ary_t *ary2);
// Shared implementations.
VALUE rary_join(VALUE ary, SEL sel, int argc, VALUE *argv);
+VALUE rary_hash(VALUE ary, SEL sel);
VALUE rary_zip(VALUE ary, SEL sel, int argc, VALUE *argv);
VALUE rary_transpose(VALUE ary, SEL sel);
VALUE rary_fill(VALUE ary, SEL sel, int argc, VALUE *argv);

0 comments on commit fdc829b

Please sign in to comment.