mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rb_ivar_foreach now free from ANYARGS
After 5e86b005c0
, 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.
This commit is contained in:
parent
50f5a0a8d6
commit
79d280a5e8
2 changed files with 8 additions and 6 deletions
|
@ -957,7 +957,7 @@ void rb_free_generic_ivar(VALUE);
|
||||||
VALUE rb_ivar_get(VALUE, ID);
|
VALUE rb_ivar_get(VALUE, ID);
|
||||||
VALUE rb_ivar_set(VALUE, ID, VALUE);
|
VALUE rb_ivar_set(VALUE, ID, VALUE);
|
||||||
VALUE rb_ivar_defined(VALUE, ID);
|
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);
|
st_index_t rb_ivar_count(VALUE);
|
||||||
VALUE rb_attr_get(VALUE, ID);
|
VALUE rb_attr_get(VALUE, ID);
|
||||||
VALUE rb_obj_instance_variables(VALUE);
|
VALUE rb_obj_instance_variables(VALUE);
|
||||||
|
|
12
variable.c
12
variable.c
|
@ -1391,9 +1391,11 @@ rb_ivar_defined(VALUE obj, ID id)
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef int rb_ivar_foreach_callback_func(ID key, VALUE val, st_data_t arg);
|
||||||
|
|
||||||
struct obj_ivar_tag {
|
struct obj_ivar_tag {
|
||||||
VALUE obj;
|
VALUE obj;
|
||||||
int (*func)(ID key, VALUE val, st_data_t arg);
|
rb_ivar_foreach_callback_func *func;
|
||||||
st_data_t arg;
|
st_data_t arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1411,7 +1413,7 @@ obj_ivar_i(st_data_t key, st_data_t index, st_data_t arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
st_table *tbl;
|
||||||
struct obj_ivar_tag data;
|
struct obj_ivar_tag data;
|
||||||
|
@ -1429,7 +1431,7 @@ obj_ivar_each(VALUE obj, int (*func)(ANYARGS), st_data_t arg)
|
||||||
|
|
||||||
struct gen_ivar_tag {
|
struct gen_ivar_tag {
|
||||||
struct gen_ivtbl *ivtbl;
|
struct gen_ivtbl *ivtbl;
|
||||||
int (*func)(ID key, VALUE val, st_data_t arg);
|
rb_ivar_foreach_callback_func *func;
|
||||||
st_data_t arg;
|
st_data_t arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1448,7 +1450,7 @@ gen_ivar_each_i(st_data_t key, st_data_t index, st_data_t data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
struct gen_ivar_tag data;
|
||||||
st_table *iv_index_tbl = RCLASS_IV_INDEX_TBL(rb_obj_class(obj));
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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;
|
if (SPECIAL_CONST_P(obj)) return;
|
||||||
switch (BUILTIN_TYPE(obj)) {
|
switch (BUILTIN_TYPE(obj)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue