From faaa986f128cfa07ca261a8e394ed58dc4adcbd1 Mon Sep 17 00:00:00 2001 From: gogotanaka Date: Sat, 17 Jan 2015 18:59:10 -0800 Subject: [PATCH 1/1] Use rb_define_alias instead of rb_define_method To: https://bugs.ruby-lang.org/ --- hash.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hash.c b/hash.c index c258115..fe9e96d 100644 --- a/hash.c +++ b/hash.c @@ -3899,7 +3899,7 @@ Init_Hash(void) rb_define_method(rb_cHash,"eql?", rb_hash_eql, 1); rb_define_method(rb_cHash,"fetch", rb_hash_fetch_m, -1); rb_define_method(rb_cHash,"[]=", rb_hash_aset, 2); - rb_define_method(rb_cHash,"store", rb_hash_aset, 2); + rb_define_alias(rb_cHash,"store", "[]="); rb_define_method(rb_cHash,"default", rb_hash_default, -1); rb_define_method(rb_cHash,"default=", rb_hash_set_default, 1); rb_define_method(rb_cHash,"default_proc", rb_hash_default_proc, 0); @@ -3907,13 +3907,13 @@ Init_Hash(void) rb_define_method(rb_cHash,"key", rb_hash_key, 1); rb_define_method(rb_cHash,"index", rb_hash_index, 1); rb_define_method(rb_cHash,"size", rb_hash_size, 0); - rb_define_method(rb_cHash,"length", rb_hash_size, 0); + rb_define_alias(rb_cHash,"length", "size"); rb_define_method(rb_cHash,"empty?", rb_hash_empty_p, 0); rb_define_method(rb_cHash,"each_value", rb_hash_each_value, 0); rb_define_method(rb_cHash,"each_key", rb_hash_each_key, 0); rb_define_method(rb_cHash,"each_pair", rb_hash_each_pair, 0); - rb_define_method(rb_cHash,"each", rb_hash_each_pair, 0); + rb_define_alias(rb_cHash,"each", "each_pair"); rb_define_method(rb_cHash,"keys", rb_hash_keys, 0); rb_define_method(rb_cHash,"values", rb_hash_values, 0); @@ -3931,18 +3931,18 @@ Init_Hash(void) rb_define_method(rb_cHash,"invert", rb_hash_invert, 0); rb_define_method(rb_cHash,"update", rb_hash_update, 1); + rb_define_alias(rb_cHash,"merge!", "update"); rb_define_method(rb_cHash,"replace", rb_hash_replace, 1); - rb_define_method(rb_cHash,"merge!", rb_hash_update, 1); rb_define_method(rb_cHash,"merge", rb_hash_merge, 1); rb_define_method(rb_cHash, "assoc", rb_hash_assoc, 1); rb_define_method(rb_cHash, "rassoc", rb_hash_rassoc, 1); rb_define_method(rb_cHash, "flatten", rb_hash_flatten, -1); - rb_define_method(rb_cHash,"include?", rb_hash_has_key, 1); - rb_define_method(rb_cHash,"member?", rb_hash_has_key, 1); - rb_define_method(rb_cHash,"has_key?", rb_hash_has_key, 1); - rb_define_method(rb_cHash,"has_value?", rb_hash_has_value, 1); - rb_define_method(rb_cHash,"key?", rb_hash_has_key, 1); - rb_define_method(rb_cHash,"value?", rb_hash_has_value, 1); + rb_define_method(rb_cHash, "has_key?", rb_hash_has_key, 1); + rb_define_alias(rb_cHash, "include?", "has_key?"); + rb_define_alias(rb_cHash, "member?", "has_key?"); + rb_define_alias(rb_cHash, "key?", "has_key?"); + rb_define_method(rb_cHash, "has_value?", rb_hash_has_value, 1); + rb_define_alias(rb_cHash, "value?", "has_value?"); rb_define_method(rb_cHash,"compare_by_identity", rb_hash_compare_by_id, 0); rb_define_method(rb_cHash,"compare_by_identity?", rb_hash_compare_by_id_p, 0); -- gogotanaka