[前][次][番号順一覧][スレッド一覧]

ruby-changes:29496

From: ko1 <ko1@a...>
Date: Sat, 22 Jun 2013 04:52:55 +0900 (JST)
Subject: [ruby-changes:29496] ko1:r41548 (trunk): * include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for second

ko1	2013-06-22 04:52:40 +0900 (Sat, 22 Jun 2013)

  New Revision: 41548

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41548

  Log:
    * include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for second
      parameter `slot'. You don't need to write a cast (VALUE *) any more.
    * class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c,
      vm.c, vm_method.c: remove cast expressions for OBJ_WRITE().

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/compile.c
    trunk/hash.c
    trunk/include/ruby/ruby.h
    trunk/iseq.c
    trunk/proc.c
    trunk/re.c
    trunk/variable.c
    trunk/vm.c
    trunk/vm_method.c

Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 41547)
+++ include/ruby/ruby.h	(revision 41548)
@@ -969,7 +969,7 @@ struct RArray { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L969
 #define RARRAY_AREF(a, i)    (RARRAY_RAWPTR(a)[i])
 #define RARRAY_ASET(a, i, v) do { \
     const VALUE _ary_ = (a); \
-    OBJ_WRITE(_ary_, (VALUE *)&RARRAY_RAWPTR(_ary_)[i], (v)); \
+    OBJ_WRITE(_ary_, &RARRAY_RAWPTR(_ary_)[i], (v)); \
 } while (0)
 
 #define RARRAY_PTR(a) ((VALUE *)RARRAY_RAWPTR(RGENGC_WB_PROTECTED_ARRAY ? OBJ_WB_GIVEUP((VALUE)a) : ((VALUE)a)))
@@ -1010,8 +1010,8 @@ struct RRational { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1010
     const VALUE den;
 };
 
-#define RRATIONAL_SET_NUM(rat, n) OBJ_WRITE((rat), ((VALUE *)(&((struct RRational *)(rat))->num)),(n))
-#define RRATIONAL_SET_DEN(rat, d) OBJ_WRITE((rat), ((VALUE *)(&((struct RRational *)(rat))->den)),(d))
+#define RRATIONAL_SET_NUM(rat, n) OBJ_WRITE((rat), &((struct RRational *)(rat))->num,(n))
+#define RRATIONAL_SET_DEN(rat, d) OBJ_WRITE((rat), &((struct RRational *)(rat))->den,(d))
 
 struct RComplex {
     struct RBasic basic;
@@ -1019,8 +1019,8 @@ struct RComplex { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1019
     const VALUE imag;
 };
 
-#define RCOMPLEX_SET_REAL(cmp, r) OBJ_WRITE((cmp), ((VALUE *)(&((struct RComplex *)(cmp))->real)),(r))
-#define RCOMPLEX_SET_IMAG(cmp, i) OBJ_WRITE((cmp), ((VALUE *)(&((struct RComplex *)(cmp))->imag)),(i))
+#define RCOMPLEX_SET_REAL(cmp, r) OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
+#define RCOMPLEX_SET_IMAG(cmp, i) OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
 
 struct RData {
     struct RBasic basic;
@@ -1131,7 +1131,7 @@ struct RStruct { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1131
    RSTRUCT(st)->as.heap.ptr)
 #define RSTRUCT_PTR(st) ((VALUE *)RSTRUCT_RAWPTR(RGENGC_WB_PROTECTED_STRUCT ? OBJ_WB_GIVEUP((VALUE)st) : (VALUE)st))
 
-#define RSTRUCT_SET(st, idx, v) OBJ_WRITE(st, (VALUE *)&RSTRUCT_RAWPTR(st)[idx], v)
+#define RSTRUCT_SET(st, idx, v) OBJ_WRITE(st, &RSTRUCT_RAWPTR(st)[idx], (v))
 #define RSTRUCT_GET(st, idx)    (RSTRUCT_RAWPTR(st)[idx])
 
 #define RBIGNUM_EMBED_LEN_MAX ((int)((sizeof(VALUE)*3)/sizeof(BDIGIT)))
@@ -1258,7 +1258,7 @@ void rb_gc_giveup_promoted_writebarrier( https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1258
 #define OBJ_SHADE(x)                OBJ_WB_GIVEUP(x) /* RGENGC terminology */
 #endif
 
-#define OBJ_WRITE(a, slot, b)       rb_obj_write((VALUE)(a), (slot), (VALUE)(b), __FILE__, __LINE__)
+#define OBJ_WRITE(a, slot, b)       rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__)
 #define OBJ_WRITTEN(a, oldv, b)     rb_obj_written((VALUE)(a), (VALUE)(oldv), (VALUE)(b), __FILE__, __LINE__)
 
 static inline VALUE
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41547)
+++ ChangeLog	(revision 41548)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jun 22 04:48:53 2013  Koichi Sasada  <ko1@a...>
+
+	* include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for second
+	  parameter `slot'. You don't need to write a cast (VALUE *) any more.
+
+	* class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c,
+	  vm.c, vm_method.c: remove cast expressions for OBJ_WRITE().
+
 Sat Jun 22 04:37:08 2013  Koichi Sasada  <ko1@a...>
 
 	* gc.c (slot_sweep_body): rename to slot_sweep().
Index: re.c
===================================================================
--- re.c	(revision 41547)
+++ re.c	(revision 41548)
@@ -2438,7 +2438,7 @@ rb_reg_initialize(VALUE obj, const char https://github.com/ruby/ruby/blob/trunk/re.c#L2438
 			  options & ARG_REG_OPTION_MASK, err,
 			  sourcefile, sourceline);
     if (!re->ptr) return -1;
-    OBJ_WRITE(obj, (VALUE *)&re->src, rb_enc_str_new(s, len, enc));
+    OBJ_WRITE(obj, &re->src, rb_enc_str_new(s, len, enc));
     OBJ_FREEZE(re->src);
     RB_GC_GUARD(unescaped);
     return 0;
@@ -2473,7 +2473,7 @@ rb_reg_s_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/re.c#L2473
     NEWOBJ_OF(re, struct RRegexp, klass, T_REGEXP | (RGENGC_WB_PROTECTED_REGEXP ? FL_WB_PROTECTED : 0));
 
     re->ptr = 0;
-    OBJ_WRITE(re, (VALUE *)&re->src, 0);
+    OBJ_WRITE(re, &re->src, 0);
     re->usecnt = 0;
 
     return (VALUE)re;
Index: variable.c
===================================================================
--- variable.c	(revision 41547)
+++ variable.c	(revision 41548)
@@ -2184,8 +2184,8 @@ rb_const_set(VALUE klass, ID id, VALUE v https://github.com/ruby/ruby/blob/trunk/variable.c#L2184
     ce->flag = visibility;
     ce->line = rb_sourceline();
     st_insert(RCLASS_CONST_TBL(klass), (st_data_t)id, (st_data_t)ce);
-    OBJ_WRITE(klass, (VALUE *)&ce->value, val);
-    OBJ_WRITE(klass, (VALUE *)&ce->file, rb_sourcefilename());
+    OBJ_WRITE(klass, &ce->value, val);
+    OBJ_WRITE(klass, &ce->file, rb_sourcefilename());
 }
 
 void
Index: iseq.c
===================================================================
--- iseq.c	(revision 41547)
+++ iseq.c	(revision 41548)
@@ -184,20 +184,20 @@ static rb_iseq_location_t * https://github.com/ruby/ruby/blob/trunk/iseq.c#L184
 iseq_location_setup(rb_iseq_t *iseq, VALUE path, VALUE absolute_path, VALUE name, size_t first_lineno)
 {
     rb_iseq_location_t *loc = &iseq->location;
-    OBJ_WRITE(iseq->self, (VALUE *)&loc->path, path);
+    OBJ_WRITE(iseq->self, &loc->path, path);
     if (RTEST(absolute_path) && rb_str_cmp(path, absolute_path) == 0) {
-	OBJ_WRITE(iseq->self, (VALUE *)&loc->absolute_path, path);
+	OBJ_WRITE(iseq->self, &loc->absolute_path, path);
     }
     else {
-	OBJ_WRITE(iseq->self, (VALUE *)&loc->absolute_path, absolute_path);
+	OBJ_WRITE(iseq->self, &loc->absolute_path, absolute_path);
     }
-    OBJ_WRITE(iseq->self, (VALUE *)&loc->label, name);
-    OBJ_WRITE(iseq->self, (VALUE *)&loc->base_label, name);
+    OBJ_WRITE(iseq->self, &loc->label, name);
+    OBJ_WRITE(iseq->self, &loc->base_label, name);
     loc->first_lineno = first_lineno;
     return loc;
 }
 
-#define ISEQ_SET_CREF(iseq, cref) OBJ_WRITE((iseq)->self, (VALUE *)&(iseq)->cref_stack, (cref))
+#define ISEQ_SET_CREF(iseq, cref) OBJ_WRITE((iseq)->self, &(iseq)->cref_stack, (cref))
 
 static void
 set_relation(rb_iseq_t *iseq, const VALUE parent)
@@ -209,7 +209,7 @@ set_relation(rb_iseq_t *iseq, const VALU https://github.com/ruby/ruby/blob/trunk/iseq.c#L209
     /* set class nest stack */
     if (type == ISEQ_TYPE_TOP) {
 	/* toplevel is private */
-	OBJ_WRITE(iseq->self, (VALUE *)&iseq->cref_stack, NEW_CREF(rb_cObject));
+	OBJ_WRITE(iseq->self, &iseq->cref_stack, NEW_CREF(rb_cObject));
 	iseq->cref_stack->nd_refinements = Qnil;
 	iseq->cref_stack->nd_visi = NOEX_PRIVATE;
 	if (th->top_wrapper) {
@@ -246,7 +246,7 @@ void https://github.com/ruby/ruby/blob/trunk/iseq.c#L246
 rb_iseq_add_mark_object(rb_iseq_t *iseq, VALUE obj)
 {
     if (!RTEST(iseq->mark_ary)) {
-	OBJ_WRITE(iseq->self, (VALUE *)&iseq->mark_ary, rb_ary_tmp_new(3));
+	OBJ_WRITE(iseq->self, &iseq->mark_ary, rb_ary_tmp_new(3));
 	RBASIC_CLEAR_CLASS(iseq->mark_ary);
     }
     rb_ary_push(iseq->mark_ary, obj);
@@ -262,7 +262,7 @@ prepare_iseq_build(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L262
     iseq->arg_rest = -1;
     iseq->arg_block = -1;
     iseq->arg_keyword = -1;
-    OBJ_WRITE(iseq->self, (VALUE *)&iseq->klass, 0);
+    OBJ_WRITE(iseq->self, &iseq->klass, 0);
     set_relation(iseq, parent);
 
     OBJ_FREEZE(name);
@@ -270,11 +270,11 @@ prepare_iseq_build(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L270
 
     iseq_location_setup(iseq, path, absolute_path, name, first_lineno);
     if (iseq != iseq->local_iseq) {
-	OBJ_WRITE(iseq->self, (VALUE *)&iseq->location.base_label, iseq->local_iseq->location.label);
+	OBJ_WRITE(iseq->self, &iseq->location.base_label, iseq->local_iseq->location.label);
     }
 
     iseq->defined_method_id = 0;
-    OBJ_WRITE(iseq->self, (VALUE *)&iseq->mark_ary, 0);
+    OBJ_WRITE(iseq->self, &iseq->mark_ary, 0);
 
     /*
      * iseq->special_block_builder = GC_GUARDED_PTR_REF(block_opt);
@@ -284,15 +284,15 @@ prepare_iseq_build(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L284
 
     iseq->compile_data = ALLOC(struct iseq_compile_data);
     MEMZERO(iseq->compile_data, struct iseq_compile_data, 1);
-    OBJ_WRITE(iseq->self, (VALUE *)&iseq->compile_data->err_info, Qnil);
-    OBJ_WRITE(iseq->self, (VALUE *)&iseq->compile_data->mark_ary, rb_ary_tmp_new(3));
+    OBJ_WRITE(iseq->self, &iseq->compile_data->err_info, Qnil);
+    OBJ_WRITE(iseq->self, &iseq->compile_data->mark_ary, rb_ary_tmp_new(3));
 
     iseq->compile_data->storage_head = iseq->compile_data->storage_current =
       (struct iseq_compile_data_storage *)
 	ALLOC_N(char, INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE +
 		sizeof(struct iseq_compile_data_storage));
 
-    OBJ_WRITE(iseq->self, (VALUE *)&iseq->compile_data->catch_table_ary, rb_ary_new());
+    OBJ_WRITE(iseq->self, &iseq->compile_data->catch_table_ary, rb_ary_new());
     iseq->compile_data->storage_head->pos = 0;
     iseq->compile_data->storage_head->next = 0;
     iseq->compile_data->storage_head->size =
@@ -302,12 +302,12 @@ prepare_iseq_build(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L302
     iseq->compile_data->option = option;
     iseq->compile_data->last_coverable_line = -1;
 
-    OBJ_WRITE(iseq->self, (VALUE *)&iseq->coverage, Qfalse);
+    OBJ_WRITE(iseq->self, &iseq->coverage, Qfalse);
     if (!GET_THREAD()->parse_in_eval) {
 	VALUE coverages = rb_get_coverages();
 	if (RTEST(coverages)) {
-	    OBJ_WRITE(iseq->self, (VALUE *)&iseq->coverage, rb_hash_lookup(coverages, path));
-	    if (NIL_P(iseq->coverage)) OBJ_WRITE(iseq->self, (VALUE *)&iseq->coverage, Qfalse);
+	    OBJ_WRITE(iseq->self, &iseq->coverage, rb_hash_lookup(coverages, path));
+	    if (NIL_P(iseq->coverage)) OBJ_WRITE(iseq->self, &iseq->coverage, Qfalse);
 	}
     }
 
@@ -1907,7 +1907,7 @@ rb_iseq_clone(VALUE iseqval, VALUE newcb https://github.com/ruby/ruby/blob/trunk/iseq.c#L1907
 
     iseq1->self = newiseq;
     if (!iseq1->orig) {
-	OBJ_WRITE(iseq1->self, (VALUE *)&iseq1->orig, iseqval);
+	OBJ_WRITE(iseq1->self, &iseq1->orig, iseqval);
     }
     if (iseq0->local_iseq == iseq0) {
 	iseq1->local_iseq = iseq1;
@@ -1919,7 +1919,7 @@ rb_iseq_clone(VALUE iseqval, VALUE newcb https://github.com/ruby/ruby/blob/trunk/iseq.c#L1919
 	if (iseq0->cref_stack->nd_next) {
 	    iseq1->cref_stack->nd_next = iseq0->cref_stack->nd_next;
 	}
-	OBJ_WRITE(iseq1, (VALUE *)&iseq1->klass, newcbase);
+	OBJ_WRITE(iseq1, &iseq1->klass, newcbase);
     }
 
     return newiseq;
@@ -2071,10 +2071,10 @@ rb_iseq_build_for_ruby2cext( https://github.com/ruby/ruby/blob/trunk/iseq.c#L2071
 
     /* copy iseq */
     MEMCPY(iseq, iseq_template, rb_iseq_t, 1); /* TODO: write barrier, *iseq = *iseq_template; */
-    OBJ_WRITE(iseq->self, (VALUE *)&iseq->location.label, rb_str_new2(name));
-    OBJ_WRITE(iseq->self, (VALUE *)&iseq->location.path, rb_str_new2(path));
+    OBJ_WRITE(iseq->self, &iseq->location.label, rb_str_new2(name));
+    OBJ_WRITE(iseq->self, &iseq->location.path, rb_str_new2(path));
     iseq->location.first_lineno = first_lineno;
-    OBJ_WRITE(iseq->self, (VALUE *)&iseq->mark_ary, 0);
+    OBJ_WRITE(iseq->self, &iseq->mark_ary, 0);
     iseq->self = iseqval;
 
     iseq->iseq = ALLOC_N(VALUE, iseq->iseq_size);
Index: compile.c
===================================================================
--- compile.c	(revision 41547)
+++ compile.c	(revision 41548)
@@ -278,7 +278,7 @@ r_value(VALUE value) https://github.com/ruby/ruby/blob/trunk/compile.c#L278
   if (compile_debug) rb_compile_bug strs;          \
   GET_THREAD()->errinfo = iseq->compile_data->err_info;  \
   rb_compile_error strs;                           \
-  OBJ_WRITE(iseq->self, (VALUE *)&iseq->compile_data->err_info, GET_THREAD()->errinfo); \
+  OBJ_WRITE(iseq->self, &iseq->compile_data->err_info, GET_THREAD()->errinfo); \
   GET_THREAD()->errinfo = tmp;                     \
   ret = 0;                                         \
   break;                                           \
@@ -1706,7 +1706,7 @@ iseq_set_exception_table(rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/compile.c#L1706
 	}
     }
 
-    OBJ_WRITE(iseq->self, (VALUE *)&iseq->compile_data->catch_table_ary, 0); /* free */
+    OBJ_WRITE(iseq->self, &iseq->compile_data->catch_table_ary, 0); /* free */
     return COMPILE_OK;
 }
 
Index: proc.c
===================================================================
--- proc.c	(revision 41547)
+++ proc.c	(revision 41548)
@@ -1467,7 +1467,7 @@ rb_mod_define_method(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/proc.c#L1467
 	GetProcPtr(body, proc);
 	if (BUILTIN_TYPE(proc->block.iseq) != T_NODE) {
 	    proc->block.iseq->defined_method_id = id;
-	    OBJ_WRITE(proc->block.iseq->self, (VALUE *)&proc->block.iseq->klass, mod);
+	    OBJ_WRITE(proc->block.iseq->self, &proc->block.iseq->klass, mod);
 	    proc->is_lambda = TRUE;
 	    proc->is_from_method = TRUE;
 	    proc->block.klass = mod;
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 41547)
+++ vm_method.c	(revision 41548)
@@ -426,16 +426,16 @@ rb_add_method(VALUE klass, ID mid, rb_me https://github.com/ruby/ruby/blob/trunk/vm_method.c#L426
       case VM_METHOD_TYPE_ATTRSET:
       case VM_METHOD_TYPE_IVAR:
 	def->body.attr.id = (ID)opts;
-	OBJ_WRITE(klass, (VALUE *)&def->body.attr.location, Qfalse);
+	OBJ_WRITE(klass, &def->body.attr.location, Qfalse);
 	th = GET_THREAD();
 	cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
 	if (cfp && (line = rb_vm_get_sourceline(cfp))) {
 	    VALUE location = rb_ary_new3(2, cfp->iseq->location.path, INT2FIX(line));
-	    OBJ_WRITE(klass, (VALUE *)&def->body.attr.location, rb_ary_freeze(location));
+	    OBJ_WRITE(klass, &def->body.attr.location, rb_ary_freeze(location));
 	}
 	break;
       case VM_METHOD_TYPE_BMETHOD:
-	OBJ_WRITE(klass, (VALUE *)&def->body.proc, (VALUE)opts);
+	OBJ_WRITE(klass, &def->body.proc, (VALUE)opts);
 	break;
       case VM_METHOD_TYPE_NOTIMPLEMENTED:
 	setup_method_cfunc_struct(&def->body.cfunc, rb_f_notimplement, -1);
Index: class.c
===================================================================
--- class.c	(revision 41547)
+++ class.c	(revision 41548)
@@ -146,7 +146,7 @@ clone_method(VALUE klass, ID mid, const https://github.com/ruby/ruby/blob/trunk/class.c#L146
 	rb_iseq_t *iseq;
 	newiseqval = rb_iseq_clone(me->def->body.iseq->self, klass);
 	GetISeqPtr(newiseqval, iseq);
-	OBJ_WRITE(iseq->self, (VALUE *)&iseq->cref_stack, rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass));
+	OBJ_WRITE(iseq->self, &iseq->cref_stack, rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass));
 	rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag);
 	RB_GC_GUARD(newiseqval);
     }
Index: hash.c
===================================================================
--- hash.c	(revision 41547)
+++ hash.c	(revision 41548)
@@ -56,7 +56,7 @@ static ID id_hash, id_yield, id_default; https://github.com/ruby/ruby/blob/trunk/hash.c#L56
 VALUE
 rb_hash_set_ifnone(VALUE hash, VALUE ifnone)
 {
-    OBJ_WRITE(hash, (VALUE *)(&RHASH(hash)->ifnone), ifnone);
+    OBJ_WRITE(hash, (&RHASH(hash)->ifnone), ifnone);
     return hash;
 }
 
Index: vm.c
===================================================================
--- vm.c	(revision 41547)
+++ vm.c	(revision 41548)
@@ -2031,7 +2031,7 @@ vm_define_method(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L2031
     /* dup */
     COPY_CREF(miseq->cref_stack, cref);
     miseq->cref_stack->nd_visi = NOEX_PUBLIC;
-    OBJ_WRITE(miseq->self, (VALUE *)&miseq->klass, klass);
+    OBJ_WRITE(miseq->self, &miseq->klass, klass);
     miseq->defined_method_id = id;
     rb_add_method(klass, id, VM_METHOD_TYPE_ISEQ, miseq, noex);
 
@@ -2532,7 +2532,7 @@ rb_vm_set_progname(VALUE filename) https://github.com/ruby/ruby/blob/trunk/vm.c#L2532
     rb_thread_t *th = GET_VM()->main_thread;
     rb_control_frame_t *cfp = (void *)(th->stack + th->stack_size);
     --cfp;
-    OBJ_WRITE(cfp->iseq->self, (VALUE *)&cfp->iseq->location.path, filename);
+    OBJ_WRITE(cfp->iseq->self, &cfp->iseq->location.path, filename);
 }
 
 #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]