ruby-changes:39601
From: nobu <ko1@a...>
Date: Wed, 26 Aug 2015 09:47:15 +0900 (JST)
Subject: [ruby-changes:39601] nobu:r51682 (trunk): id_table.h: callback function types
nobu 2015-08-26 09:47:10 +0900 (Wed, 26 Aug 2015) New Revision: 51682 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51682 Log: id_table.h: callback function types * id_table.h (rb_id_table_foreach_func_t): define callback function type for rb_id_table_foreach(). * id_table.h (rb_id_table_foreach_values_func_t): ditto for rb_id_table_foreach_values(). Modified files: trunk/id_table.c trunk/id_table.h Index: id_table.c =================================================================== --- id_table.c (revision 51681) +++ id_table.c (revision 51682) @@ -306,13 +306,13 @@ st_id_table_delete(struct st_id_table *t https://github.com/ruby/ruby/blob/trunk/id_table.c#L306 } static void -st_id_table_foreach(struct st_id_table *tbl, enum rb_id_table_iterator_result (*func)(ID id, VALUE val, void *data), void *data) +st_id_table_foreach(struct st_id_table *tbl, rb_id_table_foreach_func_t *func, void *data) { st_foreach(tbl2st(tbl), (int (*)(ANYARGS))func, (st_data_t)data); } struct values_iter_data { - enum rb_id_table_iterator_result (*values_i)(VALUE val, void *data); + rb_id_table_foreach_values_func_t *values_i; void *data; }; @@ -324,7 +324,7 @@ each_values(st_data_t key, st_data_t val https://github.com/ruby/ruby/blob/trunk/id_table.c#L324 } static void -st_id_table_foreach_values(struct st_id_table *tbl, enum rb_id_table_iterator_result (*func)(VALUE val, void *data), void *data) +st_id_table_foreach_values(struct st_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data) { struct values_iter_data values_iter_data; values_iter_data.values_i = func; @@ -702,7 +702,7 @@ list_id_table_delete(struct list_id_tabl https://github.com/ruby/ruby/blob/trunk/id_table.c#L702 } while (0) static void -list_id_table_foreach(struct list_id_table *tbl, enum rb_id_table_iterator_result (*func)(ID id, VALUE val, void *data), void *data) +list_id_table_foreach(struct list_id_table *tbl, rb_id_table_foreach_func_t *func, void *data) { int num = tbl->num; int i; @@ -720,7 +720,7 @@ list_id_table_foreach(struct list_id_tab https://github.com/ruby/ruby/blob/trunk/id_table.c#L720 } static void -list_id_table_foreach_values(struct list_id_table *tbl, enum rb_id_table_iterator_result (*func)(VALUE val, void *data), void *data) +list_id_table_foreach_values(struct list_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data) { int num = tbl->num; int i; @@ -1354,7 +1354,7 @@ hash_id_table_delete(struct hash_id_tabl https://github.com/ruby/ruby/blob/trunk/id_table.c#L1354 } static void -hash_id_table_foreach(struct hash_id_table *tbl, enum rb_id_table_iterator_result (*func)(ID id, VALUE val, void *data), void *data) +hash_id_table_foreach(struct hash_id_table *tbl, rb_id_table_foreach_func_t *func, void *data) { int i, capa = tbl->capa; @@ -1373,7 +1373,7 @@ hash_id_table_foreach(struct hash_id_tab https://github.com/ruby/ruby/blob/trunk/id_table.c#L1373 } static void -hash_id_table_foreach_values(struct hash_id_table *tbl, enum rb_id_table_iterator_result (*func)(VALUE val, void *data), void *data) +hash_id_table_foreach_values(struct hash_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data) { int i, capa = tbl->capa; @@ -1491,14 +1491,14 @@ mix_id_table_delete(struct mix_id_table https://github.com/ruby/ruby/blob/trunk/id_table.c#L1491 } static void -mix_id_table_foreach(struct mix_id_table *tbl, enum rb_id_table_iterator_result (*func)(ID id, VALUE val, void *data), void *data) +mix_id_table_foreach(struct mix_id_table *tbl, rb_id_table_foreach_func_t *func, void *data) { if (LIST_P(tbl)) list_id_table_foreach(&tbl->aux.list, func, data); else hash_id_table_foreach(&tbl->aux.hash, func, data); } static void -mix_id_table_foreach_values(struct mix_id_table *tbl, enum rb_id_table_iterator_result (*func)(VALUE val, void *data), void *data) +mix_id_table_foreach_values(struct mix_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data) { if (LIST_P(tbl)) list_id_table_foreach_values(&tbl->aux.list, func, data); else hash_id_table_foreach_values(&tbl->aux.hash, func, data); @@ -1520,9 +1520,9 @@ int rb_id_table_insert(struct rb_id_tabl https://github.com/ruby/ruby/blob/trunk/id_table.c#L1520 int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp) {return IMPL(_lookup)((ID_TABLE_IMPL_TYPE *)tbl, id, valp);} int rb_id_table_delete(struct rb_id_table *tbl, ID id) {return IMPL(_delete)((ID_TABLE_IMPL_TYPE *)tbl, id);} -void rb_id_table_foreach(struct rb_id_table *tbl, enum rb_id_table_iterator_result (*func)(ID id, VALUE val, void *data), void *data) { +void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data) { IMPL(_foreach)((ID_TABLE_IMPL_TYPE *)tbl, func, data);} -void rb_id_table_foreach_values(struct rb_id_table *tbl, enum rb_id_table_iterator_result (*func)(VALUE val, void *data), void *data) { +void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data) { IMPL(_foreach_values)((ID_TABLE_IMPL_TYPE *)tbl, func, data);} #if ID_TABLE_STARTUP_SIG Index: id_table.h =================================================================== --- id_table.h (revision 51681) +++ id_table.h (revision 51682) @@ -19,5 +19,8 @@ size_t rb_id_table_memsize(struct rb_id_ https://github.com/ruby/ruby/blob/trunk/id_table.h#L19 int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val); int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp); int rb_id_table_delete(struct rb_id_table *tbl, ID id); -void rb_id_table_foreach(struct rb_id_table *tbl, enum rb_id_table_iterator_result (*func)(ID id, VALUE val, void *data), void *data); -void rb_id_table_foreach_values(struct rb_id_table *tbl, enum rb_id_table_iterator_result (*func)(VALUE val, void *data), void *data); + +typedef enum rb_id_table_iterator_result rb_id_table_foreach_func_t(ID id, VALUE val, void *data); +typedef enum rb_id_table_iterator_result rb_id_table_foreach_values_func_t(VALUE val, void *data); +void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data); +void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/