зеркало из https://github.com/github/ruby.git
* eval.c (ruby_Init_refinement): a new function to enable
Refinements with a warning "Refinements are experimental...". * ext/refinement/refinement.c, ext/refinement/extconf.rb: a new extension library to enable Refinements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
34592fb5b6
Коммит
328e0ff5ad
|
@ -1,3 +1,11 @@
|
||||||
|
Thu Dec 6 23:27:50 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (ruby_Init_refinement): a new function to enable
|
||||||
|
Refinements with a warning "Refinements are experimental...".
|
||||||
|
|
||||||
|
* ext/refinement/refinement.c, ext/refinement/extconf.rb: a new
|
||||||
|
extension library to enable Refinements.
|
||||||
|
|
||||||
Thu Dec 6 18:23:05 2012 Shugo Maeda <shugo@ruby-lang.org>
|
Thu Dec 6 18:23:05 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
|
* revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
|
||||||
|
|
21
eval.c
21
eval.c
|
@ -1616,9 +1616,6 @@ Init_eval(void)
|
||||||
rb_define_private_method(rb_cModule, "include", rb_mod_include, -1);
|
rb_define_private_method(rb_cModule, "include", rb_mod_include, -1);
|
||||||
rb_define_private_method(rb_cModule, "prepend_features", rb_mod_prepend_features, 1);
|
rb_define_private_method(rb_cModule, "prepend_features", rb_mod_prepend_features, 1);
|
||||||
rb_define_private_method(rb_cModule, "prepend", rb_mod_prepend, -1);
|
rb_define_private_method(rb_cModule, "prepend", rb_mod_prepend, -1);
|
||||||
rb_define_private_method(rb_cModule, "using", rb_mod_using, 1);
|
|
||||||
rb_define_private_method(rb_cModule, "refine", rb_mod_refine, 1);
|
|
||||||
rb_define_method(rb_cModule, "refinements", rb_mod_refinements, 0);
|
|
||||||
|
|
||||||
rb_undef_method(rb_cClass, "module_function");
|
rb_undef_method(rb_cClass, "module_function");
|
||||||
|
|
||||||
|
@ -1629,7 +1626,6 @@ Init_eval(void)
|
||||||
rb_define_singleton_method(rb_cModule, "constants", rb_mod_s_constants, -1);
|
rb_define_singleton_method(rb_cModule, "constants", rb_mod_s_constants, -1);
|
||||||
|
|
||||||
rb_define_singleton_method(rb_vm_top_self(), "include", top_include, -1);
|
rb_define_singleton_method(rb_vm_top_self(), "include", top_include, -1);
|
||||||
rb_define_singleton_method(rb_vm_top_self(), "using", top_using, 1);
|
|
||||||
|
|
||||||
rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
|
rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
|
||||||
|
|
||||||
|
@ -1641,3 +1637,20 @@ Init_eval(void)
|
||||||
OBJ_TAINT(exception_error);
|
OBJ_TAINT(exception_error);
|
||||||
OBJ_FREEZE(exception_error);
|
OBJ_FREEZE(exception_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined __GNUC__ && __GNUC__ >= 4
|
||||||
|
#pragma GCC visibility push(default)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
ruby_Init_refinement(void)
|
||||||
|
{
|
||||||
|
rb_define_private_method(rb_cModule, "using", rb_mod_using, 1);
|
||||||
|
rb_define_private_method(rb_cModule, "refine", rb_mod_refine, 1);
|
||||||
|
rb_define_method(rb_cModule, "refinements", rb_mod_refinements, 0);
|
||||||
|
rb_define_singleton_method(rb_vm_top_self(), "using", top_using, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined __GNUC__ && __GNUC__ >= 4
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
require 'mkmf'
|
||||||
|
create_makefile('refinement')
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
void ruby_Init_refinement(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
Init_refinement(void)
|
||||||
|
{
|
||||||
|
rb_warn("Refinements are experimental, and the behavior may change in future versions of Ruby!");
|
||||||
|
ruby_Init_refinement();
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require_relative 'envutil'
|
require_relative 'envutil'
|
||||||
|
|
||||||
|
require "refinement"
|
||||||
|
|
||||||
class TestRefinement < Test::Unit::TestCase
|
class TestRefinement < Test::Unit::TestCase
|
||||||
class Foo
|
class Foo
|
||||||
def x
|
def x
|
||||||
|
@ -480,7 +482,9 @@ class TestRefinement < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_main_using
|
def test_main_using
|
||||||
assert_in_out_err([], <<-INPUT, %w(:C :M), [])
|
assert_in_out_err([], <<-INPUT, %w(:C :M), /Refinements are experimental/)
|
||||||
|
require "refinement"
|
||||||
|
|
||||||
class C
|
class C
|
||||||
def foo
|
def foo
|
||||||
:C
|
:C
|
||||||
|
@ -775,7 +779,9 @@ class TestRefinement < Test::Unit::TestCase
|
||||||
assert_equal("original", UsingMethodCache::M::ORIGINAL_FOO)
|
assert_equal("original", UsingMethodCache::M::ORIGINAL_FOO)
|
||||||
assert_equal("M2", UsingMethodCache::M::M2_FOO)
|
assert_equal("M2", UsingMethodCache::M::M2_FOO)
|
||||||
|
|
||||||
assert_in_out_err([], <<-INPUT, %w(:M1 :M2), [])
|
assert_in_out_err([], <<-INPUT, %w(:M1 :M2), /Refinements are experimental/)
|
||||||
|
require "refinement"
|
||||||
|
|
||||||
class C
|
class C
|
||||||
def foo
|
def foo
|
||||||
"original"
|
"original"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче