mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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:
parent
34592fb5b6
commit
328e0ff5ad
5 changed files with 44 additions and 6 deletions
|
@ -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>
|
||||
|
||||
* 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, "prepend_features", rb_mod_prepend_features, 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");
|
||||
|
||||
|
@ -1629,7 +1626,6 @@ Init_eval(void)
|
|||
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(), "using", top_using, 1);
|
||||
|
||||
rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
|
||||
|
||||
|
@ -1641,3 +1637,20 @@ Init_eval(void)
|
|||
OBJ_TAINT(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
|
||||
|
|
3
ext/refinement/extconf.rb
Normal file
3
ext/refinement/extconf.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
require 'mkmf'
|
||||
create_makefile('refinement')
|
||||
|
8
ext/refinement/refinement.c
Normal file
8
ext/refinement/refinement.c
Normal file
|
@ -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_relative 'envutil'
|
||||
|
||||
require "refinement"
|
||||
|
||||
class TestRefinement < Test::Unit::TestCase
|
||||
class Foo
|
||||
def x
|
||||
|
@ -480,7 +482,9 @@ class TestRefinement < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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
|
||||
def foo
|
||||
:C
|
||||
|
@ -775,7 +779,9 @@ class TestRefinement < Test::Unit::TestCase
|
|||
assert_equal("original", UsingMethodCache::M::ORIGINAL_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
|
||||
def foo
|
||||
"original"
|
||||
|
|
Loading…
Reference in a new issue