summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-07 11:22:31 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-07 11:22:31 +0000
commit9cadf0c03906f49f41e4222248c6a48e72bdb82f (patch)
treeb346b3621f380acab8d108f1d12c7c8d06f15b07 /eval.c
parent06f2a86f1a57ded8177f0611bb107f0c4bcc2e70 (diff)
* eval.c (Init_eval): enable Refinements by default.
[ruby-core:51286] [Bug #7667] * eval.c (rb_mod_refine, top_using): show a warning when Module#refine or main.using is called at the first time. * ext/refinement/*: removed the extension library "refinement". * test/ruby/test_refinement.rb: fix for the above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/eval.c b/eval.c
index c2b17532a9..ea78edc66a 100644
--- a/eval.c
+++ b/eval.c
@@ -1039,6 +1039,17 @@ rb_mod_prepend(int argc, VALUE *argv, VALUE module)
return module;
}
+static void
+warn_refinements_once()
+{
+ static int warned = 0;
+
+ if (warned)
+ return;
+ rb_warn("Refinements are experimental, and the behavior may change in future versions of Ruby!");
+ warned = 1;
+}
+
static VALUE
hidden_identity_hash_new()
{
@@ -1170,6 +1181,7 @@ rb_mod_refine(VALUE module, VALUE klass)
rb_thread_t *th = GET_THREAD();
rb_block_t *block = rb_vm_control_frame_block_ptr(th->cfp);
+ warn_refinements_once();
if (!block) {
rb_raise(rb_eArgError, "no block given");
}
@@ -1334,6 +1346,7 @@ top_using(VALUE self, VALUE module)
NODE *cref = rb_vm_cref();
rb_control_frame_t *prev_cfp = previous_frame(GET_THREAD());
+ warn_refinements_once();
if (cref->nd_next || (prev_cfp && prev_cfp->me)) {
rb_raise(rb_eRuntimeError, "using is permitted only at toplevel");
}
@@ -1527,6 +1540,8 @@ 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, "refine", rb_mod_refine, 1);
+ rb_undef_method(rb_cClass, "refine");
rb_undef_method(rb_cClass, "module_function");
@@ -1537,6 +1552,8 @@ 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_private_method(rb_singleton_class(rb_vm_top_self()),
+ "using", top_using, 1);
rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
@@ -1548,20 +1565,3 @@ 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, "refine", rb_mod_refine, 1);
- rb_undef_method(rb_cClass, "refine");
- rb_define_private_method(rb_singleton_class(rb_vm_top_self()),
- "using", top_using, 1);
-}
-
-#if defined __GNUC__ && __GNUC__ >= 4
-#pragma GCC visibility pop
-#endif