ruby-changes:38689
From: ko1 <ko1@a...>
Date: Fri, 5 Jun 2015 01:02:19 +0900 (JST)
Subject: [ruby-changes:38689] ko1:r50770 (trunk): * method.h: constify rb_method_refined_t::orig_me.
ko1 2015-06-05 01:02:01 +0900 (Fri, 05 Jun 2015) New Revision: 50770 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50770 Log: * method.h: constify rb_method_refined_t::orig_me. Also constify the following functions. * rb_resolve_refined_method() * rb_method_entry_with_refinements() * rb_method_entry_without_refinements() * rb_method_entry_copy()'s parameter. * class.c: catch up this fix. * vm_insnhelper.c: ditto. * vm_method.c: ditto. Modified files: trunk/ChangeLog trunk/class.c trunk/method.h trunk/vm_insnhelper.c trunk/vm_method.c Index: method.h =================================================================== --- method.h (revision 50769) +++ method.h (revision 50770) @@ -78,7 +78,7 @@ typedef struct rb_method_alias_struct { https://github.com/ruby/ruby/blob/trunk/method.h#L78 } rb_method_alias_t; typedef struct rb_method_refined_struct { - struct rb_method_entry_struct *orig_me; + const struct rb_method_entry_struct *orig_me; } rb_method_refined_t; typedef struct rb_method_definition_struct { @@ -120,13 +120,13 @@ rb_method_entry_t *rb_add_method(VALUE k https://github.com/ruby/ruby/blob/trunk/method.h#L120 rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr); rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id); void rb_add_refined_method_entry(VALUE refined_class, ID mid); -rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, - const rb_method_entry_t *me, - VALUE *defined_class_ptr); -rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id, - VALUE *defined_class_ptr); -rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, - VALUE *defined_class_ptr); +const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, + const rb_method_entry_t *me, + VALUE *defined_class_ptr); +const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id, + VALUE *defined_class_ptr); +const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, + VALUE *defined_class_ptr); rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id, VALUE *define_class_ptr); rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex); @@ -144,7 +144,7 @@ void rb_sweep_method_entry(void *vm); https://github.com/ruby/ruby/blob/trunk/method.h#L144 rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_definition_t *def); rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me); -void rb_method_entry_copy(rb_method_entry_t *dst, rb_method_entry_t *src); +void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src); void rb_scope_visibility_set(rb_method_visibility_t); Index: ChangeLog =================================================================== --- ChangeLog (revision 50769) +++ ChangeLog (revision 50770) @@ -1,3 +1,20 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jun 5 00:55:21 2015 Koichi Sasada <ko1@a...> + + * method.h: constify rb_method_refined_t::orig_me. + + Also constify the following functions. + + * rb_resolve_refined_method() + * rb_method_entry_with_refinements() + * rb_method_entry_without_refinements() + * rb_method_entry_copy()'s parameter. + + * class.c: catch up this fix. + + * vm_insnhelper.c: ditto. + + * vm_method.c: ditto. + Thu Jun 4 12:47:54 SGT 2015 SHIBATA Hiroshi <hsbt@r...> * array.c: Revert r50763. because "reentered" is not typo. Index: vm_method.c =================================================================== --- vm_method.c (revision 50769) +++ vm_method.c (revision 50770) @@ -307,7 +307,7 @@ rb_method_definition_create(rb_method_vi https://github.com/ruby/ruby/blob/trunk/vm_method.c#L307 } static void -rb_method_definition_reset(rb_method_entry_t *me, rb_method_definition_t *def) +rb_method_definition_reset(const rb_method_entry_t *me, rb_method_definition_t *def) { switch(def->type) { case VM_METHOD_TYPE_ISEQ: @@ -372,7 +372,7 @@ rb_method_entry_clone(const rb_method_en https://github.com/ruby/ruby/blob/trunk/vm_method.c#L372 } void -rb_method_entry_copy(rb_method_entry_t *dst, rb_method_entry_t *src) +rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src) { rb_method_definition_reset(dst, rb_method_definition_clone(src->def)); dst->called_id = src->called_id; @@ -709,7 +709,7 @@ rb_method_entry(VALUE klass, ID id, VALU https://github.com/ruby/ruby/blob/trunk/vm_method.c#L709 return rb_method_entry_get_without_cache(klass, id, defined_class_ptr); } -static rb_method_entry_t * +static const rb_method_entry_t * get_original_method_entry(VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr) @@ -731,7 +731,7 @@ get_original_method_entry(VALUE refineme https://github.com/ruby/ruby/blob/trunk/vm_method.c#L731 } } -rb_method_entry_t * +const rb_method_entry_t * rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me, VALUE *defined_class_ptr) { @@ -759,12 +759,12 @@ rb_resolve_refined_method(VALUE refineme https://github.com/ruby/ruby/blob/trunk/vm_method.c#L759 } } -rb_method_entry_t * +const rb_method_entry_t * rb_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class_ptr) { VALUE defined_class; - rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class); + const rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class); if (me && me->def->type == VM_METHOD_TYPE_REFINED) { const rb_cref_t *cref = rb_vm_cref(); @@ -778,12 +778,12 @@ rb_method_entry_with_refinements(VALUE k https://github.com/ruby/ruby/blob/trunk/vm_method.c#L778 return me; } -rb_method_entry_t * +const rb_method_entry_t * rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class_ptr) { VALUE defined_class; - rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class); + const rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class); if (me && me->def->type == VM_METHOD_TYPE_REFINED) { me = rb_resolve_refined_method(Qnil, me, &defined_class); @@ -910,8 +910,7 @@ rb_export_method(VALUE klass, ID name, r https://github.com/ruby/ruby/blob/trunk/vm_method.c#L910 int rb_method_boundp(VALUE klass, ID id, int ex) { - rb_method_entry_t *me = - rb_method_entry_without_refinements(klass, id, 0); + const rb_method_entry_t *me = rb_method_entry_without_refinements(klass, id, 0); if (me != 0) { rb_method_definition_t *def = me->def; @@ -1371,7 +1370,7 @@ rb_alias(VALUE klass, ID alias_name, ID https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1370 { const VALUE target_klass = klass; VALUE defined_class; - rb_method_entry_t *orig_me; + const rb_method_entry_t *orig_me; rb_method_visibility_t visi = METHOD_VISI_UNDEF; if (NIL_P(klass)) { Index: class.c =================================================================== --- class.c (revision 50769) +++ class.c (revision 50770) @@ -914,7 +914,7 @@ move_refined_method(st_data_t key, st_da https://github.com/ruby/ruby/blob/trunk/class.c#L914 if (me->def->type == VM_METHOD_TYPE_REFINED) { if (me->def->body.refined.orig_me) { - rb_method_entry_t *orig_me = me->def->body.refined.orig_me, *new_me; + const rb_method_entry_t *orig_me = me->def->body.refined.orig_me, *new_me; me->def->body.refined.orig_me = NULL; new_me = rb_method_entry_clone(me); st_add_direct(tbl, key, (st_data_t) new_me); Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 50769) +++ vm_insnhelper.c (revision 50770) @@ -1136,7 +1136,7 @@ check_match(VALUE pattern, VALUE target, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1136 /* fall through */ case VM_CHECKMATCH_TYPE_CASE: { VALUE defined_class; - rb_method_entry_t *me = rb_method_entry_with_refinements(CLASS_OF(pattern), idEqq, &defined_class); + const rb_method_entry_t *me = rb_method_entry_with_refinements(CLASS_OF(pattern), idEqq, &defined_class); if (me) { return vm_call0(GET_THREAD(), pattern, idEqq, 1, &target, me, defined_class); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/