[#43181] [Ruby 1.9-Bug#4387][Open] test_socket_connect_nonblock(TestSocketAddrinfo) がまれに失敗する — Motohiro KOSAKI <redmine@...>
Bug #4387: test_socket_connect_nonblock(TestSocketAddrinfo) がまれに失敗する
6 messages
2011/02/09
[#43186] [Ruby 1.9-Bug#4388][Open] open-uriで環境変数http_proxyを使うときに認証付きのProxyが使えません — あつし よしだ <redmine@...>
Bug #4388: open-uri=E3=81=A7=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0http_prox=
11 messages
2011/02/10
[#43192] [Ruby 1.9-Bug#4388] open-uriで環境変数http_proxyを使うときに認証付きのProxyが使えません
— あつし よしだ <redmine@...>
2011/02/11
チケット #4388 が更新されました。 (by あつし よしだ)
[#43193] Re: [Ruby 1.9-Bug#4388] open-uriで環境変数http_proxyを使うときに認証付きのProxyが使えません
— Tanaka Akira <akr@...>
2011/02/11
2011年2月11日12:59 あつし よしだ <redmine@ruby-lang.org>:
[#43195] Re: [Ruby 1.9-Bug#4388] open-uriで環境変数http_proxyを使うときに認証付きのProxyが使えません
— Mitsuru Ogino <ogino@...>
2011/02/11
荻野と言います。
[#43197] Re: [Ruby 1.9-Bug#4388] open-uriで環境変数http_proxyを使うときに認証付きのProxyが使えません
— Yukihiro Matsumoto <matz@...>
2011/02/11
まつもと ゆきひろです
[#43199] Re: [ruby-changes:18827] Ruby:r30852 (trunk): * thread.c (rb_thread_io_blocking_region): new function to run — SASADA Koichi <ko1@...>
ささだです.
4 messages
2011/02/12
[#43203] [Ruby 1.9-Bug#4397][Open] test-mkmf fails due to compilation errors — Shyouhei Urabe <redmine@...>
Bug #4397: test-mkmf fails due to compilation errors
10 messages
2011/02/14
[#43204] Re: [Ruby 1.9-Bug#4397][Open] test-mkmf fails due to compilation errors
— KOSAKI Motohiro <kosaki.motohiro@...>
2011/02/14
2011年2月14日18:12 Shyouhei Urabe <redmine@ruby-lang.org>:
[#43205] Re: [Ruby 1.9-Bug#4397][Open] test-mkmf fails due to compilation errors
— Urabe Shyouhei <shyouhei@...>
2011/02/14
(2011/02/14 18:24), KOSAKI Motohiro wrote:
[#43206] Re: [Ruby 1.9-Bug#4397][Open] test-mkmf fails due to compilation errors
— KOSAKI Motohiro <kosaki.motohiro@...>
2011/02/14
> これでもまだ長いと思われるので更に解説すると、debugflagsによりgccはstrict ansi
[#43222] Rubyのtest-allを並列化するパッチを書きました — "Shota Fukumori (sora_h)" <sorah@...>
sora_hです。おはようございます。
8 messages
2011/02/17
[#43226] [Ruby 1.9-Feature#4415][Open] Rubyのtest-allを並列化するパッチが完成しました — Shota Fukumori <redmine@...>
Feature #4415: Rubyのtest-allを並列化するパッチが完成しました
6 messages
2011/02/21
[#43241] [ANN] redmine.ruby-lang.orgメンテナンスのお知らせ — "Yuki Sonoda (Yugui)" <yugui@...>
-----BEGIN PGP SIGNED MESSAGE-----
7 messages
2011/02/22
[#43263] Re: [ruby-list:47910] [ANN] redmine.ruby-lang.orgメンテナンスのお知らせ
— "Yuki Sonoda (Yugui)" <yugui@...>
2011/02/23
-----BEGIN PGP SIGNED MESSAGE-----
[#43265] Re: [ruby-list:47910] [ANN] redmine.ruby-lang.orgメンテナンスのお知らせ
— Fujioka <fuj@...>
2011/02/24
xibbarこと藤岡です。
[#43253] [Ruby 1.9 - Bug #4430] (Open) 新型redmine.ruby-lang.orgのテスト — Yuki Sonoda <yugui@...>
5 messages
2011/02/23
[#43272] [Ruby 1.9 - Bug #4443] [Open] odd evaluation order in a multiple assignment — Yusuke Endoh <mame@...>
13 messages
2011/02/24
[#43276] iseq_compile_each()でのマジックナンバ — きたざわけんいち <peisunstar@...>
きたざわです。
15 messages
2011/02/27
[#43303] Re: iseq_compile_each()でのマジックナンバ
— nagachika <nagachika00@...>
2011/03/04
近永と申します。
[#43304] Re: iseq_compile_each()でのマジックナンバ
— Yusuke ENDOH <mame@...>
2011/03/04
遠藤です。
[ruby-dev:43194] [Ruby 1.9-Feature#4043] グローバル関数current_classの提案
From:
Makoto Kishimoto <redmine@...>
Date:
2011-02-11 08:53:46 UTC
List:
ruby-dev #43194
=E3=83=81=E3=82=B1=E3=83=83=E3=83=88 #4043 =E3=81=8C=E6=9B=B4=E6=96=B0=E3= =81=95=E3=82=8C=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82 (by Makoto Kishimoto)= =E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB patch-current-class =E8=BF=BD=E5=8A=A0= Module.current =E3=81=AB +1 =E6=96=B0=E3=81=97=E3=81=84=E3=83=91=E3=83=83=E3=83=81=E4=BD=9C=E3=82=8A=E3= =81=BE=E3=81=97=E3=81=9F ---------------------------------------- http://redmine.ruby-lang.org/issues/show/4043 ---------------------------------------- http://redmine.ruby-lang.org
Attachments (1)
patch-current-class
(2.17 KB, text/x-diff)
diff --git a/eval.c b/eval.c
index 5fe00e1..22a0a60 100644
--- a/eval.c
+++ b/eval.c
@@ -347,6 +347,20 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
return rb_const_list(data);
}
+/*
+ * call-seq:
+ * Module.current -> Module
+ *
+ * Returns "current class".
+ */
+
+VALUE rb_vm_cref_cls(void);
+static VALUE
+rb_mod_current(void)
+{
+ return rb_vm_cref_cls();
+}
+
void
rb_frozen_class_p(VALUE klass)
{
@@ -1144,6 +1158,8 @@ Init_eval(void)
rb_define_singleton_method(rb_cModule, "nesting", rb_mod_nesting, 0);
rb_define_singleton_method(rb_cModule, "constants", rb_mod_s_constants, -1);
+ rb_define_singleton_method(rb_cModule, "current", rb_mod_current, 0);
+
rb_define_singleton_method(rb_vm_top_self(), "include", top_include, -1);
rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index ce6e8a6..b6277dc 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1000,4 +1000,28 @@ class TestModule < Test::Unit::TestCase
INPUT
assert_in_out_err([], src, %w(Object :ok), [])
end
+
+ class ModuleCurrentTestModule1
+ CURRENT = Module.current
+
+ def self.foo
+ Module.current
+ end
+
+ def foo
+ Module.current
+ end
+ end
+
+ def test_module_current
+ assert_equal(TestModule, Module.current)
+ assert_equal(ModuleCurrentTestModule1, ModuleCurrentTestModule1::CURRENT)
+ assert_equal(ModuleCurrentTestModule1, ModuleCurrentTestModule1.foo)
+ module_current_test = ModuleCurrentTestModule1.new
+ assert_equal(ModuleCurrentTestModule1, module_current_test.foo)
+ foo = ModuleCurrentTestModule1.module_eval{Module.current}
+ assert_equal(ModuleCurrentTestModule1, foo)
+ foo = ModuleCurrentTestModule1.instance_eval{Module.current}
+ assert_equal("#<Class:TestModule::ModuleCurrentTestModule1>", foo.to_s)
+ end
end
diff --git a/vm.c b/vm.c
index d0c2592..03f15e7 100644
--- a/vm.c
+++ b/vm.c
@@ -827,6 +827,12 @@ rb_vm_cref(void)
return vm_get_cref(cfp->iseq, cfp->lfp, cfp->dfp);
}
+VALUE
+rb_vm_cref_cls(void)
+{
+ return rb_vm_cref()->nd_clss;
+}
+
#if 0
void
debug_cref(NODE *cref)