ruby-changes:57324
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 27 Aug 2019 18:58:42 +0900 (JST)
Subject: [ruby-changes:57324] 卜部昌平: 79d280a5e8 (master): rb_ivar_foreach now free from ANYARGS
https://git.ruby-lang.org/ruby.git/commit/?id=79d280a5e8 From 79d280a5e855d623957638b6d73f530995e03cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Tue, 27 Aug 2019 12:08:32 +0900 Subject: rb_ivar_foreach now free from ANYARGS After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit adds a function prototype for rb_ivar_foreach. Luckily this change revealed no problematic usage of the function. diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 51d4132..3e418c3 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -957,7 +957,7 @@ void rb_free_generic_ivar(VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L957 VALUE rb_ivar_get(VALUE, ID); VALUE rb_ivar_set(VALUE, ID, VALUE); VALUE rb_ivar_defined(VALUE, ID); -void rb_ivar_foreach(VALUE, int (*)(ANYARGS), st_data_t); +void rb_ivar_foreach(VALUE, int (*)(ID, VALUE, st_data_t), st_data_t); st_index_t rb_ivar_count(VALUE); VALUE rb_attr_get(VALUE, ID); VALUE rb_obj_instance_variables(VALUE); diff --git a/variable.c b/variable.c index bc79dd6..4a92212 100644 --- a/variable.c +++ b/variable.c @@ -1391,9 +1391,11 @@ rb_ivar_defined(VALUE obj, ID id) https://github.com/ruby/ruby/blob/trunk/variable.c#L1391 return Qfalse; } +typedef int rb_ivar_foreach_callback_func(ID key, VALUE val, st_data_t arg); + struct obj_ivar_tag { VALUE obj; - int (*func)(ID key, VALUE val, st_data_t arg); + rb_ivar_foreach_callback_func *func; st_data_t arg; }; @@ -1411,7 +1413,7 @@ obj_ivar_i(st_data_t key, st_data_t index, st_data_t arg) https://github.com/ruby/ruby/blob/trunk/variable.c#L1413 } static void -obj_ivar_each(VALUE obj, int (*func)(ANYARGS), st_data_t arg) +obj_ivar_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg) { st_table *tbl; struct obj_ivar_tag data; @@ -1429,7 +1431,7 @@ obj_ivar_each(VALUE obj, int (*func)(ANYARGS), st_data_t arg) https://github.com/ruby/ruby/blob/trunk/variable.c#L1431 struct gen_ivar_tag { struct gen_ivtbl *ivtbl; - int (*func)(ID key, VALUE val, st_data_t arg); + rb_ivar_foreach_callback_func *func; st_data_t arg; }; @@ -1448,7 +1450,7 @@ gen_ivar_each_i(st_data_t key, st_data_t index, st_data_t data) https://github.com/ruby/ruby/blob/trunk/variable.c#L1450 } static void -gen_ivar_each(VALUE obj, int (*func)(ANYARGS), st_data_t arg) +gen_ivar_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg) { struct gen_ivar_tag data; st_table *iv_index_tbl = RCLASS_IV_INDEX_TBL(rb_obj_class(obj)); @@ -1531,7 +1533,7 @@ rb_copy_generic_ivar(VALUE clone, VALUE obj) https://github.com/ruby/ruby/blob/trunk/variable.c#L1533 } void -rb_ivar_foreach(VALUE obj, int (*func)(ANYARGS), st_data_t arg) +rb_ivar_foreach(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg) { if (SPECIAL_CONST_P(obj)) return; switch (BUILTIN_TYPE(obj)) { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/