summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-19 14:09:20 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-19 14:09:20 (GMT)
commit0fb2cd458b13576c837ed10b94eb8bb296e85118 (patch)
treeff42ba330d15a0808e98f7fb1fecac8d673c613a /class.c
parent97d71ce8f0802ef20dae819f3012828381b408f5 (diff)
class.c: add callback argument
* class.c (rb_class_foreach_subclass): add argument for callback function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/class.c b/class.c
index f90b080..fe6f38e 100644
--- a/class.c
+++ b/class.c
@@ -110,7 +110,7 @@ rb_class_remove_from_module_subclasses(VALUE klass)
}
void
-rb_class_foreach_subclass(VALUE klass, void(*f)(VALUE))
+rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE arg)
{
rb_subclass_entry_t *cur = RCLASS_EXT(klass)->subclasses;
@@ -119,20 +119,32 @@ rb_class_foreach_subclass(VALUE klass, void(*f)(VALUE))
while (cur) {
VALUE curklass = cur->klass;
cur = cur->next;
- f(curklass);
+ f(curklass, arg);
}
}
+static void
+class_detach_subclasses(VALUE klass, VALUE arg)
+{
+ rb_class_remove_from_super_subclasses(klass);
+}
+
void
rb_class_detach_subclasses(VALUE klass)
{
- rb_class_foreach_subclass(klass, rb_class_remove_from_super_subclasses);
+ rb_class_foreach_subclass(klass, class_detach_subclasses, Qnil);
+}
+
+static void
+class_detach_module_subclasses(VALUE klass, VALUE arg)
+{
+ rb_class_remove_from_module_subclasses(klass);
}
void
rb_class_detach_module_subclasses(VALUE klass)
{
- rb_class_foreach_subclass(klass, rb_class_remove_from_module_subclasses);
+ rb_class_foreach_subclass(klass, class_detach_module_subclasses, Qnil);
}
/**