From 4b3a1f77e14696780265f4c05bfa01a5216f8f99 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 30 Mar 2012 22:40:54 +0000 Subject: [PATCH] * hash.c, marshal.c, object.c, variable.c: fix callback argument types of iterators. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ hash.c | 5 +++-- marshal.c | 6 +++++- object.c | 5 ++++- variable.c | 38 +++++++++++++++++++++++++++++--------- 5 files changed, 46 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index c60f4e805b..8ae7df0f28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Mar 31 07:40:51 2012 Nobuyoshi Nakada + + * hash.c, marshal.c, object.c, variable.c: fix callback argument types + of iterators. + Thu Mar 29 23:50:15 2012 Nobuyoshi Nakada * st.c (st_update): pass pointer to key to the callback function. diff --git a/hash.c b/hash.c index e9937ffe71..d86bf65c61 100644 --- a/hash.c +++ b/hash.c @@ -184,9 +184,10 @@ hash_foreach_ensure(VALUE hash) } static VALUE -hash_foreach_call(struct hash_foreach_arg *arg) +hash_foreach_call(VALUE arg) { - if (st_foreach_check(RHASH(arg->hash)->ntbl, hash_foreach_iter, (st_data_t)arg, Qundef)) { + VALUE hash = ((struct hash_foreach_arg *)arg)->hash; + if (st_foreach_check(RHASH(hash)->ntbl, hash_foreach_iter, (st_data_t)arg, (st_data_t)Qundef)) { rb_raise(rb_eRuntimeError, "hash modified during iteration"); } return Qnil; diff --git a/marshal.c b/marshal.c index 3b9f93e545..dee1891106 100644 --- a/marshal.c +++ b/marshal.c @@ -506,8 +506,12 @@ w_uclass(VALUE obj, VALUE super, struct dump_arg *arg) } static int -w_obj_each(ID id, VALUE value, struct dump_call_arg *arg) +w_obj_each(st_data_t key, st_data_t val, st_data_t a) { + ID id = (ID)key; + VALUE value = (VALUE)val; + struct dump_call_arg *arg = (struct dump_call_arg *)a; + if (id == rb_id_encoding()) return ST_CONTINUE; if (id == rb_intern("E")) return ST_CONTINUE; w_symbol(id, arg->arg); diff --git a/object.c b/object.c index 63af8a2f90..d43095d8c3 100644 --- a/object.c +++ b/object.c @@ -400,8 +400,11 @@ rb_inspect(VALUE obj) } static int -inspect_i(ID id, VALUE value, VALUE str) +inspect_i(st_data_t k, st_data_t v, st_data_t a) { + ID id = (ID)k; + VALUE value = (VALUE)v; + VALUE str = (VALUE)a; VALUE str2; const char *ivname; diff --git a/variable.c b/variable.c index 523bc58e75..20d86ace37 100644 --- a/variable.c +++ b/variable.c @@ -70,8 +70,11 @@ fc_path(struct fc_result *fc, ID name) } static int -fc_i(ID key, rb_const_entry_t *ce, struct fc_result *res) +fc_i(st_data_t k, st_data_t v, st_data_t a) { + ID key = (ID)k; + rb_const_entry_t *ce = (rb_const_entry_t *)v; + struct fc_result *res = (struct fc_result *)a; VALUE value = ce->value; if (!rb_is_const_id(key)) return ST_CONTINUE; @@ -455,8 +458,10 @@ readonly_setter(VALUE val, ID id, void *data, struct global_variable *gvar) } static int -mark_global_entry(ID key, struct global_entry *entry) +mark_global_entry(st_data_t k, st_data_t v, st_data_t a) { + ID key = (ID)key; + struct global_entry *entry = (struct global_entry *)v; struct trace_var *trace; struct global_variable *var = entry->var; @@ -746,8 +751,10 @@ rb_gvar_defined(struct global_entry *entry) } static int -gvar_i(ID key, struct global_entry *entry, VALUE ary) +gvar_i(st_data_t k, st_data_t v, st_data_t a) { + ID key = (ID)k; + VALUE ary = (VALUE)a; rb_ary_push(ary, ID2SYM(key)); return ST_CONTINUE; } @@ -916,15 +923,18 @@ rb_mark_generic_ivar(VALUE obj) } static int -givar_mark_i(ID key, VALUE value) +givar_mark_i(st_data_t k, st_data_t v, st_data_t a) { + VALUE value = (VALUE)v; rb_gc_mark(value); return ST_CONTINUE; } static int -givar_i(VALUE obj, st_table *tbl) +givar_i(st_data_t k, st_data_t v, st_data_t a) { + VALUE obj = (VALUE)k; + st_table *tbl = (st_table *)v; if (rb_special_const_p(obj)) { st_foreach_safe(tbl, givar_mark_i, 0); } @@ -1241,8 +1251,11 @@ rb_ivar_count(VALUE obj) } static int -ivar_i(ID key, VALUE val, VALUE ary) +ivar_i(st_data_t k, st_data_t v, st_data_t a) { + ID key = (ID)k; + VALUE ary = (VALUE)a; + if (rb_is_instance_id(key)) { rb_ary_push(ary, ID2SYM(key)); } @@ -1855,8 +1868,12 @@ rb_const_remove(VALUE mod, ID id) } static int -sv_i(ID key, rb_const_entry_t *ce, st_table *tbl) +sv_i(st_data_t k, st_data_t v, st_data_t a) { + ID key = (ID)k; + rb_const_entry_t *ce = (rb_const_entry_t *)v; + st_table *tbl = (st_table *)a; + if (rb_is_const_id(key)) { if (!st_lookup(tbl, (st_data_t)key, 0)) { st_insert(tbl, (st_data_t)key, (st_data_t)ce); @@ -2301,8 +2318,11 @@ rb_define_class_variable(VALUE klass, const char *name, VALUE val) } static int -cv_i(ID key, VALUE value, VALUE ary) +cv_i(st_data_t k, st_data_t v, st_data_t a) { + ID key = (ID)k; + VALUE ary = (VALUE)a; + if (rb_is_class_id(key)) { VALUE kval = ID2SYM(key); if (!rb_ary_includes(ary, kval)) { @@ -2334,7 +2354,7 @@ rb_mod_class_variables(VALUE obj) VALUE ary = rb_ary_new(); if (RCLASS_IV_TBL(obj)) { - st_foreach_safe(RCLASS_IV_TBL(obj), cv_i, ary); + st_foreach_safe(RCLASS_IV_TBL(obj), cv_i, (st_data_t)ary); } return ary; }