summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-12 15:03:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-12 15:03:02 +0000
commitd7feab06ccaacff4e673f22e55a9b8f537fa89ba (patch)
treefeaacfbcd5bc13c8509c59b914d084ae19b14b30 /vm_method.c
parent797749c21938b27098d758a2d837b42996c0c310 (diff)
* vm_method.c (rb_add_method, rb_add_method_me): call method added
hook after definition. [ruby-core:25536] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/vm_method.c b/vm_method.c
index 1091eadbcd..c263defda2 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -212,6 +212,12 @@ rb_add_method_def(VALUE klass, ID mid, rb_method_type_t type, rb_method_definiti
st_insert(mtbl, mid, (st_data_t) me);
+ return me;
+}
+
+static void
+method_added(VALUE klass, ID mid)
+{
if (mid != ID_ALLOCATOR && ruby_running) {
if (FL_TEST(klass, FL_SINGLETON)) {
rb_funcall(rb_iv_get(klass, "__attached__"), singleton_added, 1, ID2SYM(mid));
@@ -220,8 +226,6 @@ rb_add_method_def(VALUE klass, ID mid, rb_method_type_t type, rb_method_definiti
rb_funcall(klass, added, 1, ID2SYM(mid));
}
}
-
- return me;
}
rb_method_entry_t *
@@ -260,6 +264,7 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_
default:
rb_bug("rb_add_method: unsupported method type (%d)\n", type);
}
+ method_added(klass, mid);
return me;
}
@@ -267,7 +272,9 @@ rb_method_entry_t *
rb_add_method_me(VALUE klass, ID mid, const rb_method_entry_t *me, rb_method_flag_t noex)
{
rb_method_type_t type = me->def ? me->def->type : VM_METHOD_TYPE_UNDEF;
- return rb_add_method_def(klass, mid, type, me->def, noex);
+ rb_method_entry_t *newme = rb_add_method_def(klass, mid, type, me->def, noex);
+ method_added(klass, mid);
+ return newme;
}
void