mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
797749c219
commit
d7feab06cc
4 changed files with 36 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sun Sep 13 00:03:01 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_method.c (rb_add_method, rb_add_method_me): call method added
|
||||||
|
hook after definition. [ruby-core:25536]
|
||||||
|
|
||||||
Sat Sep 12 22:47:24 2009 Tanaka Akira <akr@fsij.org>
|
Sat Sep 12 22:47:24 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* lib/open-uri.rb (URI::FTP#buffer_open): use the port specified in
|
* lib/open-uri.rb (URI::FTP#buffer_open): use the port specified in
|
||||||
|
|
|
@ -755,4 +755,23 @@ class TestModule < Test::Unit::TestCase
|
||||||
c = eval("class C\u{df}; self; end")
|
c = eval("class C\u{df}; self; end")
|
||||||
assert_equal("TestModule::C\u{df}", c.name, '[ruby-core:24600]')
|
assert_equal("TestModule::C\u{df}", c.name, '[ruby-core:24600]')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_method_added
|
||||||
|
memo = []
|
||||||
|
mod = Module.new do
|
||||||
|
mod = self
|
||||||
|
(class << self ; self ; end).class_eval do
|
||||||
|
define_method :method_added do |sym|
|
||||||
|
memo << sym
|
||||||
|
memo << mod.instance_methods(false)
|
||||||
|
memo << (mod.instance_method(sym) rescue nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def f
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert_equal :f, memo.shift
|
||||||
|
assert_equal mod.instance_methods(false), memo.shift
|
||||||
|
assert_equal mod.instance_method(:f), memo.shift
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#define RUBY_VERSION "1.9.2"
|
#define RUBY_VERSION "1.9.2"
|
||||||
#define RUBY_RELEASE_DATE "2009-09-12"
|
#define RUBY_RELEASE_DATE "2009-09-13"
|
||||||
#define RUBY_PATCHLEVEL -1
|
#define RUBY_PATCHLEVEL -1
|
||||||
#define RUBY_BRANCH_NAME "trunk"
|
#define RUBY_BRANCH_NAME "trunk"
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
#define RUBY_VERSION_TEENY 1
|
#define RUBY_VERSION_TEENY 1
|
||||||
#define RUBY_RELEASE_YEAR 2009
|
#define RUBY_RELEASE_YEAR 2009
|
||||||
#define RUBY_RELEASE_MONTH 9
|
#define RUBY_RELEASE_MONTH 9
|
||||||
#define RUBY_RELEASE_DAY 12
|
#define RUBY_RELEASE_DAY 13
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
13
vm_method.c
13
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);
|
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 (mid != ID_ALLOCATOR && ruby_running) {
|
||||||
if (FL_TEST(klass, FL_SINGLETON)) {
|
if (FL_TEST(klass, FL_SINGLETON)) {
|
||||||
rb_funcall(rb_iv_get(klass, "__attached__"), singleton_added, 1, ID2SYM(mid));
|
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));
|
rb_funcall(klass, added, 1, ID2SYM(mid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return me;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_method_entry_t *
|
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:
|
default:
|
||||||
rb_bug("rb_add_method: unsupported method type (%d)\n", type);
|
rb_bug("rb_add_method: unsupported method type (%d)\n", type);
|
||||||
}
|
}
|
||||||
|
method_added(klass, mid);
|
||||||
return me;
|
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_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;
|
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
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue