diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-27 13:57:14 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-27 13:57:14 +0000 |
commit | ffb09d8e87f7792e137c1d74fb33ea6cbcb0046c (patch) | |
tree | bae564eefcc17851d370372f3c25a838040fe3dc | |
parent | ceab460fcae4136404d3d85e4ac62620394a25a8 (diff) |
eval.c: rename "rb_frozen_class_p" to "rb_class_modify_check"
Just refactoring. Despite its name, the function does NOT return a
boolean but raises an exception when the class given is frozen.
I don't think the new name "rb_class_modify_check" is the best, but
it follows the precedeint "rb_ary_modify_check", and is definitely
better than "*_p".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | class.c | 2 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | include/ruby/backward.h | 3 | ||||
-rw-r--r-- | include/ruby/intern.h | 1 | ||||
-rw-r--r-- | internal.h | 1 | ||||
-rw-r--r-- | variable.c | 4 | ||||
-rw-r--r-- | vm_method.c | 8 |
7 files changed, 12 insertions, 9 deletions
@@ -852,7 +852,7 @@ static int include_modules_at(const VALUE klass, VALUE c, VALUE module, int sear static void ensure_includable(VALUE klass, VALUE module) { - rb_frozen_class_p(klass); + rb_class_modify_check(klass); Check_Type(module, T_MODULE); if (!NIL_P(rb_refinement_module_get_refined_class(module))) { rb_raise(rb_eArgError, "refinement module is not allowed"); @@ -416,7 +416,7 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod) * \ingroup class */ void -rb_frozen_class_p(VALUE klass) +rb_class_modify_check(VALUE klass) { if (SPECIAL_CONST_P(klass)) { noclass: diff --git a/include/ruby/backward.h b/include/ruby/backward.h index 586746f37d..f77c89a234 100644 --- a/include/ruby/backward.h +++ b/include/ruby/backward.h @@ -38,6 +38,9 @@ DECLARE_DEPRECATED_FEATURE(2.2, rb_frame_pop); #define DECLARE_DEPRECATED_INTERNAL_FEATURE(func) \ NORETURN(ERRORFUNC(("deprecated internal function"), DEPRECATED(void func(void)))) +/* eval.c */ +NORETURN(ERRORFUNC(("internal function"), void rb_frozen_class_p(VALUE))); + /* error.c */ DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_compile_error); DECLARE_DEPRECATED_INTERNAL_FEATURE(rb_compile_error_with_enc); diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 9ecd8ce8e2..813145ed2d 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -203,7 +203,6 @@ VALUE rb_class_protected_instance_methods(int, const VALUE*, VALUE); VALUE rb_class_private_instance_methods(int, const VALUE*, VALUE); VALUE rb_obj_singleton_methods(int, const VALUE*, VALUE); void rb_define_method_id(VALUE, ID, VALUE (*)(ANYARGS), int); -void rb_frozen_class_p(VALUE); void rb_undef(VALUE, ID); void rb_define_protected_method(VALUE, const char*, VALUE (*)(ANYARGS), int); void rb_define_private_method(VALUE, const char*, VALUE (*)(ANYARGS), int); diff --git a/internal.h b/internal.h index 45c499d869..9075d16360 100644 --- a/internal.h +++ b/internal.h @@ -1254,6 +1254,7 @@ PRINTF_ARGS(VALUE rb_warning_string(const char *fmt, ...), 1, 2); /* eval.c */ VALUE rb_refinement_module_get_refined_class(VALUE module); extern ID ruby_static_id_signo, ruby_static_id_status; +void rb_class_modify_check(VALUE); #define id_signo ruby_static_id_signo #define id_status ruby_static_id_status diff --git a/variable.c b/variable.c index 383fab3143..32e71fccb4 100644 --- a/variable.c +++ b/variable.c @@ -2848,7 +2848,7 @@ set_const_visibility(VALUE mod, int argc, const VALUE *argv, rb_const_entry_t *ce; ID id; - rb_frozen_class_p(mod); + rb_class_modify_check(mod); if (argc == 0) { rb_warning("%"PRIsVALUE" with no argument is just ignored", QUOTE_ID(rb_frame_callee())); @@ -2898,7 +2898,7 @@ rb_deprecate_constant(VALUE mod, const char *name) ID id; long len = strlen(name); - rb_frozen_class_p(mod); + rb_class_modify_check(mod); if (!(id = rb_check_id_cstr(name, len, NULL)) || !(ce = rb_const_lookup(mod, id))) { rb_name_err_raise("constant %2$s::%1$s not defined", diff --git a/vm_method.c b/vm_method.c index 520d41f36b..7a06e39505 100644 --- a/vm_method.c +++ b/vm_method.c @@ -539,7 +539,7 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil } } - rb_frozen_class_p(klass); + rb_class_modify_check(klass); if (FL_TEST(klass, RMODULE_IS_REFINEMENT)) { VALUE refined_class = rb_refinement_module_get_refined_class(klass); @@ -985,7 +985,7 @@ remove_method(VALUE klass, ID mid) VALUE self = klass; klass = RCLASS_ORIGIN(klass); - rb_frozen_class_p(klass); + rb_class_modify_check(klass); if (mid == object_id || mid == id__send__ || mid == idInitialize) { rb_warn("removing `%s' may cause serious problems", rb_id2name(mid)); } @@ -1198,7 +1198,7 @@ rb_undef(VALUE klass, ID id) if (NIL_P(klass)) { rb_raise(rb_eTypeError, "no class to undef method"); } - rb_frozen_class_p(klass); + rb_class_modify_check(klass); if (id == object_id || id == id__send__ || id == idInitialize) { rb_warn("undefining `%s' may cause serious problems", rb_id2name(id)); } @@ -1555,7 +1555,7 @@ rb_alias(VALUE klass, ID alias_name, ID original_name) rb_raise(rb_eTypeError, "no class to make alias"); } - rb_frozen_class_p(klass); + rb_class_modify_check(klass); again: orig_me = search_method(klass, original_name, &defined_class); |