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

ruby-changes:30964

From: ko1 <ko1@a...>
Date: Wed, 25 Sep 2013 17:24:42 +0900 (JST)
Subject: [ruby-changes:30964] ko1:r43043 (trunk): * include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().

ko1	2013-09-25 17:24:34 +0900 (Wed, 25 Sep 2013)

  New Revision: 43043

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

  Log:
    * include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
      RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
      usecase of this macro is not acquire raw pointer, but acquire
      read-only pointer. So we rename to better name.
      RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
      (I expect that nobody use it).
    * array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
      string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
      catch up this change.

  Modified files:
    trunk/ChangeLog
    trunk/array.c
    trunk/compile.c
    trunk/cont.c
    trunk/enumerator.c
    trunk/gc.c
    trunk/include/ruby/ruby.h
    trunk/proc.c
    trunk/random.c
    trunk/string.c
    trunk/struct.c
    trunk/thread.c
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
Index: array.c
===================================================================
--- array.c	(revision 43042)
+++ array.c	(revision 43043)
@@ -217,7 +217,7 @@ ary_resize_capa(VALUE ary, long capacity https://github.com/ruby/ruby/blob/trunk/array.c#L217
     else {
         if (!ARY_EMBED_P(ary)) {
             long len = RARRAY_LEN(ary);
-	    const VALUE *ptr = RARRAY_RAWPTR(ary);
+	    const VALUE *ptr = RARRAY_CONST_PTR(ary);
             if (len > capacity) len = capacity;
             MEMCPY((VALUE *)RARRAY(ary)->as.ary, ptr, VALUE, len);
             FL_SET_EMBED(ary);
@@ -324,9 +324,9 @@ rb_ary_modify(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L324
             ARY_SET_EMBED_LEN(ary, len);
         }
 	else if (ARY_SHARED_OCCUPIED(shared) && len > (RARRAY_LEN(shared)>>1)) {
-	    long shift = RARRAY_RAWPTR(ary) - RARRAY_RAWPTR(shared);
+	    long shift = RARRAY_CONST_PTR(ary) - RARRAY_CONST_PTR(shared);
 	    FL_UNSET_SHARED(ary);
-	    ARY_SET_PTR(ary, RARRAY_RAWPTR(shared));
+	    ARY_SET_PTR(ary, RARRAY_CONST_PTR(shared));
 	    ARY_SET_CAPA(ary, RARRAY_LEN(shared));
 	    RARRAY_PTR_USE(ary, ptr, {
 		MEMMOVE(ptr, ptr+shift, VALUE, len);
@@ -336,7 +336,7 @@ rb_ary_modify(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L336
 	}
         else {
             VALUE *ptr = ALLOC_N(VALUE, len);
-            MEMCPY(ptr, RARRAY_RAWPTR(ary), VALUE, len);
+            MEMCPY(ptr, RARRAY_CONST_PTR(ary), VALUE, len);
             rb_ary_unshare(ary);
             ARY_SET_CAPA(ary, len);
             ARY_SET_PTR(ary, ptr);
@@ -354,7 +354,7 @@ ary_ensure_room_for_push(VALUE ary, long https://github.com/ruby/ruby/blob/trunk/array.c#L354
 	if (new_len > RARRAY_EMBED_LEN_MAX) {
 	    VALUE shared = ARY_SHARED(ary);
 	    if (ARY_SHARED_OCCUPIED(shared)) {
-		if (RARRAY_RAWPTR(ary) - RARRAY_RAWPTR(shared) + new_len <= RARRAY_LEN(shared)) {
+		if (RARRAY_CONST_PTR(ary) - RARRAY_CONST_PTR(shared) + new_len <= RARRAY_LEN(shared)) {
 		    rb_ary_modify_check(ary);
 		}
 		else {
@@ -577,7 +577,7 @@ ary_make_shared(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L577
         FL_UNSET_EMBED(shared);
 
         ARY_SET_LEN((VALUE)shared, ARY_CAPA(ary));
-	ARY_SET_PTR((VALUE)shared, RARRAY_RAWPTR(ary));
+	ARY_SET_PTR((VALUE)shared, RARRAY_CONST_PTR(ary));
 	ary_mem_clear((VALUE)shared, RARRAY_LEN(ary), ARY_CAPA(ary) - RARRAY_LEN(ary));
 	FL_SET_SHARED_ROOT(shared);
 	ARY_SET_SHARED_NUM((VALUE)shared, 1);
@@ -595,7 +595,7 @@ ary_make_substitution(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L595
 
     if (len <= RARRAY_EMBED_LEN_MAX) {
 	VALUE subst = rb_ary_new2(len);
-	ary_memcpy(subst, 0, len, RARRAY_RAWPTR(ary));
+	ary_memcpy(subst, 0, len, RARRAY_CONST_PTR(ary));
         ARY_SET_EMBED_LEN(subst, len);
         return subst;
     }
@@ -711,8 +711,8 @@ rb_ary_initialize(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/array.c#L711
 
     rb_ary_modify(ary);
     if (argc == 0) {
-	if (ARY_OWNS_HEAP_P(ary) && RARRAY_RAWPTR(ary) != 0) {
-	    xfree((void *)RARRAY_RAWPTR(ary));
+	if (ARY_OWNS_HEAP_P(ary) && RARRAY_CONST_PTR(ary) != 0) {
+	    xfree((void *)RARRAY_CONST_PTR(ary));
 	}
         rb_ary_unshare_safe(ary);
         FL_SET_EMBED(ary);
@@ -817,7 +817,7 @@ ary_make_partial(VALUE ary, VALUE klass, https://github.com/ruby/ruby/blob/trunk/array.c#L817
 
     if (len <= RARRAY_EMBED_LEN_MAX) {
         VALUE result = ary_alloc(klass);
-	ary_memcpy(result, 0, len, RARRAY_RAWPTR(ary) + offset);
+	ary_memcpy(result, 0, len, RARRAY_CONST_PTR(ary) + offset);
         ARY_SET_EMBED_LEN(result, len);
         return result;
     }
@@ -826,7 +826,7 @@ ary_make_partial(VALUE ary, VALUE klass, https://github.com/ruby/ruby/blob/trunk/array.c#L826
         FL_UNSET_EMBED(result);
 
         shared = ary_make_shared(ary);
-        ARY_SET_PTR(result, RARRAY_RAWPTR(ary));
+        ARY_SET_PTR(result, RARRAY_CONST_PTR(ary));
         ARY_SET_LEN(result, RARRAY_LEN(ary));
         rb_ary_set_shared(result, shared);
 
@@ -1081,8 +1081,8 @@ ary_ensure_room_for_unshift(VALUE ary, i https://github.com/ruby/ruby/blob/trunk/array.c#L1081
 	VALUE shared = ARY_SHARED(ary);
 	capa = RARRAY_LEN(shared);
 	if (ARY_SHARED_OCCUPIED(shared) && capa > new_len) {
-	    head = RARRAY_RAWPTR(ary);
-	    sharedp = RARRAY_RAWPTR(shared);
+	    head = RARRAY_CONST_PTR(ary);
+	    sharedp = RARRAY_CONST_PTR(shared);
 	    goto makeroom_if_need;
 	}
     }
@@ -1099,7 +1099,7 @@ ary_ensure_room_for_unshift(VALUE ary, i https://github.com/ruby/ruby/blob/trunk/array.c#L1099
 	capa = ARY_CAPA(ary);
 	ary_make_shared(ary);
 
-	head = sharedp = RARRAY_RAWPTR(ary);
+	head = sharedp = RARRAY_CONST_PTR(ary);
 	goto makeroom;
       makeroom_if_need:
 	if (head - sharedp < argc) {
@@ -1432,7 +1432,7 @@ rb_ary_index(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/array.c#L1432
     if (rb_block_given_p())
 	rb_warn("given block not used");
     len = RARRAY_LEN(ary);
-    ptr = RARRAY_RAWPTR(ary);
+    ptr = RARRAY_CONST_PTR(ary);
     for (i=0; i<len; i++) {
 	VALUE e = ptr[i];
 	switch (rb_equal_opt(e, val)) {
@@ -1444,7 +1444,7 @@ rb_ary_index(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/array.c#L1444
 	    continue;
 	}
 	len = RARRAY_LEN(ary);
-	ptr = RARRAY_RAWPTR(ary);
+	ptr = RARRAY_CONST_PTR(ary);
     }
     return Qnil;
 }
@@ -1495,7 +1495,7 @@ rb_ary_rindex(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/array.c#L1495
     val = argv[0];
     if (rb_block_given_p())
 	rb_warn("given block not used");
-    ptr = RARRAY_RAWPTR(ary);
+    ptr = RARRAY_CONST_PTR(ary);
     while (i--) {
 	VALUE e = ptr[i];
 	switch (rb_equal_opt(e, val)) {
@@ -1509,7 +1509,7 @@ rb_ary_rindex(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/array.c#L1509
 	if (i > (len = RARRAY_LEN(ary))) {
 	    i = len;
 	}
-	ptr = RARRAY_RAWPTR(ary);
+	ptr = RARRAY_CONST_PTR(ary);
     }
     return Qnil;
 }
@@ -1555,7 +1555,7 @@ rb_ary_splice(VALUE ary, long beg, long https://github.com/ruby/ruby/blob/trunk/array.c#L1555
 	len = beg + rlen;
 	ary_mem_clear(ary, RARRAY_LEN(ary), beg - RARRAY_LEN(ary));
 	if (rlen > 0) {
-	    ary_memcpy(ary, beg, rlen, RARRAY_RAWPTR(rpl));
+	    ary_memcpy(ary, beg, rlen, RARRAY_CONST_PTR(rpl));
 	}
 	ARY_SET_LEN(ary, len);
     }
@@ -1575,7 +1575,7 @@ rb_ary_splice(VALUE ary, long beg, long https://github.com/ruby/ruby/blob/trunk/array.c#L1575
 	    ARY_SET_LEN(ary, alen);
 	}
 	if (rlen > 0) {
-	    MEMMOVE(RARRAY_PTR(ary) + beg, RARRAY_RAWPTR(rpl), VALUE, rlen);
+	    MEMMOVE(RARRAY_PTR(ary) + beg, RARRAY_CONST_PTR(rpl), VALUE, rlen);
 	}
     }
 }
@@ -1879,7 +1879,7 @@ rb_ary_dup(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L1879
 {
     long len = RARRAY_LEN(ary);
     VALUE dup = rb_ary_new2(len);
-    ary_memcpy(dup, 0, len, RARRAY_RAWPTR(ary));
+    ary_memcpy(dup, 0, len, RARRAY_CONST_PTR(ary));
     ARY_SET_LEN(dup, len);
     return dup;
 }
@@ -1887,7 +1887,7 @@ rb_ary_dup(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L1887
 VALUE
 rb_ary_resurrect(VALUE ary)
 {
-    return rb_ary_new4(RARRAY_LEN(ary), RARRAY_RAWPTR(ary));
+    return rb_ary_new4(RARRAY_LEN(ary), RARRAY_CONST_PTR(ary));
 }
 
 extern VALUE rb_output_fs;
@@ -2179,8 +2179,8 @@ rb_ary_reverse_m(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2179
     VALUE dup = rb_ary_new2(len);
 
     if (len > 0) {
-	const VALUE *p1 = RARRAY_RAWPTR(ary);
-	VALUE *p2 = (VALUE *)RARRAY_RAWPTR(dup) + len - 1;
+	const VALUE *p1 = RARRAY_CONST_PTR(ary);
+	VALUE *p2 = (VALUE *)RARRAY_CONST_PTR(dup) + len - 1;
 	do *p2-- = *p1++; while (--len > 0);
     }
     ARY_SET_LEN(dup, RARRAY_LEN(ary));
@@ -2279,7 +2279,7 @@ rb_ary_rotate_m(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/array.c#L2279
     rotated = rb_ary_new2(len);
     if (len > 0) {
 	cnt = rotate_count(cnt, len);
-	ptr = RARRAY_RAWPTR(ary);
+	ptr = RARRAY_CONST_PTR(ary);
 	len -= cnt;
 	ary_memcpy(rotated, 0, len, ptr + cnt);
 	ary_memcpy(rotated, len, cnt, ptr);
@@ -2422,7 +2422,7 @@ rb_ary_sort_bang(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2422
                 else {
 		    xfree((void *)ARY_HEAP_PTR(ary));
                 }
-                ARY_SET_PTR(ary, RARRAY_RAWPTR(tmp));
+                ARY_SET_PTR(ary, RARRAY_CONST_PTR(tmp));
                 ARY_SET_HEAP_LEN(ary, len);
                 ARY_SET_CAPA(ary, RARRAY_LEN(tmp));
             }
@@ -2986,7 +2986,7 @@ rb_ary_slice_bang(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/array.c#L2986
 	    len = orig_len - pos;
 	}
 	if (len == 0) return rb_ary_new2(0);
-	arg2 = rb_ary_new4(len, RARRAY_RAWPTR(ary)+pos);
+	arg2 = rb_ary_new4(len, RARRAY_CONST_PTR(ary)+pos);
 	RBASIC_SET_CLASS(arg2, rb_obj_class(ary));
 	rb_ary_splice(ary, pos, len, Qundef);
 	return arg2;
@@ -3290,7 +3290,7 @@ rb_ary_replace(VALUE copy, VALUE orig) https://github.com/ruby/ruby/blob/trunk/array.c#L3290
             FL_UNSET_SHARED(copy);
         }
         FL_SET_EMBED(copy);
-	ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_RAWPTR(orig));
+	ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR(orig));
         if (shared) {
             rb_ary_decrement_share(shared);
         }
@@ -3305,7 +3305,7 @@ rb_ary_replace(VALUE copy, VALUE orig) https://github.com/ruby/ruby/blob/trunk/array.c#L3305
             rb_ary_unshare_safe(copy);
         }
         FL_UNSET_EMBED(copy);
-        ARY_SET_PTR(copy, RARRAY_RAWPTR(orig));
+        ARY_SET_PTR(copy, RARRAY_CONST_PTR(orig));
         ARY_SET_LEN(copy, RARRAY_LEN(orig));
         rb_ary_set_shared(copy, shared);
     }
@@ -3463,8 +3463,8 @@ rb_ary_plus(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/array.c#L3463
     len = xlen + ylen;
     z = rb_ary_new2(len);
 
-    ary_memcpy(z, 0, xlen, RARRAY_RAWPTR(x));
-    ary_memcpy(z, xlen, ylen, RARRAY_RAWPTR(y));
+    ary_memcpy(z, 0, xlen, RARRAY_CONST_PTR(x));
+    ary_memcpy(z, xlen, ylen, RARRAY_CONST_PTR(y));
     ARY_SET_LEN(z, len);
     return z;
 }
@@ -3540,16 +3540,16 @@ rb_ary_times(VALUE ary, VALUE times) https://github.com/ruby/ruby/blob/trunk/array.c#L3540
     ary2 = ary_new(rb_obj_class(ary), len);
     ARY_SET_LEN(ary2, len);
 
-    ptr = RARRAY_RAWPTR(ary);
+    ptr = RARRAY_CONST_PTR(ary);
     t = RARRAY_LEN(ary);
     if (0 < t) {
 	ary_memcpy(ary2, 0, t, ptr);
 	while (t <= len/2) {
-	    ary_memcpy(ary2, t, t, RARRAY_RAWPTR(ary2));
+	    ary_memcpy(ary2, t, t, RARRAY_CONST_PTR(ary2));
             t *= 2;
         }
         if (t < len) {
-	    ary_memcpy(ary2, t, len-t, RARRAY_RAWPTR(ary2));
+	    ary_memcpy(ary2, t, len-t, RARRAY_CONST_PTR(ary2));
         }
     }
   out:
@@ -3635,8 +3635,8 @@ recursive_equal(VALUE ary1, VALUE ary2, https://github.com/ruby/ruby/blob/trunk/array.c#L3635
 
     if (recur) return Qtrue; /* Subtle! */
 
-    p1 = RARRAY_RAWPTR(ary1);
-    p2 = RARRAY_RAWPTR(ary2);
+    p1 = RARRAY_CONST_PTR(ary1);
+    p2 = RARRAY_CONST_PTR(ary2);
     len1 = RARRAY_LEN(ary1);
 
     for (i = 0; i < len1; i++) {
@@ -3647,8 +3647,8 @@ recursive_equal(VALUE ary1, VALUE ary2, https://github.com/ruby/ruby/blob/trunk/array.c#L3647
 		    return Qfalse;
 		if (len1 < i)
 		    return Qtrue;
-		p1 = RARRAY_RAWPTR(ary1) + i;
-		p2 = RARRAY_RAWPTR(ary2) + i;
+		p1 = RARRAY_CONST_PTR(ary1) + i;
+		p2 = RARRAY_CONST_PTR(ary2) + i;
 	    }
 	    else {
 		return Qfalse;
@@ -3685,7 +3685,7 @@ rb_ary_equal(VALUE ary1, VALUE ary2) https://github.com/ruby/ruby/blob/trunk/array.c#L3685
 	return rb_equal(ary2, ary1);
     }
     if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
-    if (RARRAY_RAWPTR(ary1) == RARRAY_RAWPTR(ary2)) return Qtrue;
+    if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
     return rb_exec_recursive_paired(recursive_equal, ary1, ary2, ary2);
 }
 
@@ -3716,7 +3716,7 @@ rb_ary_eql(VALUE ary1, VALUE ary2) https://github.com/ruby/ruby/blob/trunk/array.c#L3716
     if (ary1 == ary2) return Qtrue;
     if (!RB_TYPE_P(ary2, T_ARRAY)) return Qfalse;
     if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
-    if (RARRAY_RAWPTR(ary1) == RARRAY_RAWPTR(ary2)) return Qtrue;
+    if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
     return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2);
 }
 
@@ -4160,14 +4160,14 @@ rb_ary_compact_bang(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L4160
     long n;
 
     rb_ary_modify(ary);
-    p = t = (VALUE *)RARRAY_RAWPTR(ary); /* WB: no new reference */
+    p = t = (VALUE *)RARRAY_CONST_PTR(ary); /* WB: no new reference */
     end = p + RARRAY_LEN(ary);
 
     while (t < end) {
 	if (NIL_P(*t)) t++;
 	else *p++ = *t++;
     }
-    n = p - RARRAY_RAWPTR(ary);
+    n = p - RARRAY_CONST_PTR(ary);
     if (RARRAY_LEN(ary) == n) {
 	return Qnil;
     }
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 43042)
+++ include/ruby/ruby.h	(revision 43043)
@@ -881,13 +881,12 @@ struct RArray { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L881
 
 #define RARRAY_LENINT(ary) rb_long2int(RARRAY_LEN(ary))
 
-/* DO NOT USE THIS MACRO DIRECTLY */
-#define RARRAY_RAWPTR(a) \
-  ((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ? \
-   RARRAY(a)->as.ary : \
-   RARRAY(a)->as.heap.ptr)
+#define RARRAY_CONST_PTR(a) \
+  ((const VALUE *)((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ? \
+		   RARRAY(a)->as.ary : \
+		   RARRAY(a)->as.heap.ptr))
 
-#define RARRAY_PTR_USE_START(a) RARRAY_RAWPTR(a)
+#define RARRAY_PTR_USE_START(a) ((VALUE *)RARRAY_CONST_PTR(a))
 #define RARRAY_PTR_USE_END(a) /* */
 
 #define RARRAY_PTR_USE(ary, ptr_name, expr) do { \
@@ -897,13 +896,13 @@ struct RArray { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L896
     RARRAY_PTR_USE_END(_ary); \
 } while (0)
 
-#define RARRAY_AREF(a, i)    (RARRAY_RAWPTR(a)[i])
+#define RARRAY_AREF(a, i)    (RARRAY_CONST_PTR(a)[i])
 #define RARRAY_ASET(a, i, v) do { \
     const VALUE _ary_ = (a); \
-    OBJ_WRITE(_ary_, &RARRAY_RAWPTR(_ary_)[i], (v)); \
+    OBJ_WRITE(_ary_, &RARRAY_CONST_PTR(_ary_)[i], (v)); \
 } while (0)
 
-#define RARRAY_PTR(a) ((VALUE *)RARRAY_RAWPTR(RGENGC_WB_PROTECTED_ARRAY ? OBJ_WB_UNPROTECT((VALUE)a) : ((VALUE)a)))
+#define RARRAY_PTR(a) ((VALUE *)RARRAY_CONST_PTR(RGENGC_WB_PROTECTED_ARRAY ? OBJ_WB_UNPROTECT((VALUE)a) : ((VALUE)a)))
 
 struct RRegexp {
     struct RBasic basic;
@@ -1056,14 +1055,14 @@ struct RStruct { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1055
             (RSTRUCT_EMBED_LEN_MASK >> RSTRUCT_EMBED_LEN_SHIFT)) : \
      RSTRUCT(st)->as.heap.len)
 #define RSTRUCT_LENINT(st) rb_long2int(RSTRUCT_LEN(st))
-#define RSTRUCT_RAWPTR(st) \
+#define RSTRUCT_CONST_PTR(st) \
   ((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ? \
    RSTRUCT(st)->as.ary : \
    RSTRUCT(st)->as.heap.ptr)
-#define RSTRUCT_PTR(st) ((VALUE *)RSTRUCT_RAWPTR(RGENGC_WB_PROTECTED_STRUCT ? OBJ_WB_UNPROTECT((VALUE)st) : (VALUE)st))
+#define RSTRUCT_PTR(st) ((VALUE *)RSTRUCT_CONST_PTR(RGENGC_WB_PROTECTED_STRUCT ? OBJ_WB_UNPROTECT((VALUE)st) : (VALUE)st))
 
-#define RSTRUCT_SET(st, idx, v) OBJ_WRITE(st, &RSTRUCT_RAWPTR(st)[idx], (v))
-#define RSTRUCT_GET(st, idx)    (RSTRUCT_RAWPTR(st)[idx])
+#define RSTRUCT_SET(st, idx, v) OBJ_WRITE(st, &RSTRUCT_CONST_PTR(st)[idx], (v))
+#define RSTRUCT_GET(st, idx)    (RSTRUCT_CONST_PTR(st)[idx])
 
 #ifndef RBIGNUM_EMBED_LEN_MAX
 # define RBIGNUM_EMBED_LEN_MAX ((int)((sizeof(VALUE)*3)/sizeof(BDIGIT)))
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43042)
+++ ChangeLog	(revision 43043)
@@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Sep 25 17:12:08 2013  Koichi Sasada  <ko1@a...>
+
+	* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
+	  RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
+	  usecase of this macro is not acquire raw pointer, but acquire
+	  read-only pointer. So we rename to better name.
+	  RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
+	  (I expect that nobody use it).
+
+	* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c, 
+	  string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
+	  catch up this change.
+
 Wed Sep 25 16:58:33 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* internal.h (rb_float_value, rb_float_new): move inline functions
Index: enumerator.c
===================================================================
--- enumerator.c	(revision 43042)
+++ enumerator.c	(revision 43043)
@@ -1044,7 +1044,7 @@ enumerator_size(VALUE obj) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1044
     }
     if (e->args) {
 	argc = (int)RARRAY_LEN(e->args);
-	argv = RARRAY_RAWPTR(e->args);
+	argv = RARRAY_CONST_PTR(e->args);
     }
     size = rb_check_funcall(e->size, id_call, argc, argv);
     if (size != Qundef) return size;
Index: string.c
===================================================================
--- string.c	(revision 43042)
+++ string.c	(revision 43043)
@@ -1366,7 +1366,7 @@ rb_str_format_m(VALUE str, VALUE arg) https://github.com/ruby/ruby/blob/trunk/string.c#L1366
     volatile VALUE tmp = rb_check_array_type(arg);
 
     if (!NIL_P(tmp)) {
-	return rb_str_format(RARRAY_LENINT(tmp), RARRAY_RAWPTR(tmp), str);
+	return rb_str_format(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp), str);
     }
     return rb_str_format(1, &arg, str);
 }
Index: compile.c
===================================================================
--- compile.c	(revision 43042)
+++ compile.c	(revision 43043)
@@ -1174,7 +1174,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L1174
 
 	    iseq->arg_opts = i;
 	    iseq->arg_opt_table = ALLOC_N(VALUE, i);
-	    MEMCPY(iseq->arg_opt_table, RARRAY_RAWPTR(labels), VALUE, i);
+	    MEMCPY(iseq->arg_opt_table, RARRAY_CONST_PTR(labels), VALUE, i);
 	    for (j = 0; j < i; j++) {
 		iseq->arg_opt_table[j] &= ~1;
 	    }
@@ -1675,13 +1675,13 @@ iseq_set_exception_table(rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/compile.c#L1675
     struct iseq_catch_table_entry *entry;
 
     tlen = (int)RARRAY_LEN(iseq->compile_data->catch_table_ary);
-    tptr = RARRAY_RAWPTR(iseq->compile_data->catch_table_ary);
+    tptr = RARRAY_CONST_PTR(iseq->compile_data->catch_table_ary);
 
     iseq->catch_table = tlen ? ALLOC_N(struct iseq_catch_table_entry, tlen) : 0;
     iseq->catch_table_size = tlen;
 
     for (i = 0; i < tlen; i++) {
-	ptr = RARRAY_RAWPTR(tptr[i]);
+	ptr = RARRAY_CONST_PTR(tptr[i]);
 	entry = &iseq->catch_table[i];
 	entry->type = (enum catch_type)(ptr[0] & 0xffff);
 	entry->start = label_get_position((LABEL *)(ptr[1] & ~1));
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 43042)
+++ vm_eval.c	(revision 43043)
@@ -1510,7 +1510,7 @@ yield_under(VALUE under, VALUE self, VAL https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1510
 	return vm_yield_with_cref(th, 1, &self, cref);
     }
     else {
-	return vm_yield_with_cref(th, RARRAY_LENINT(values), RARRAY_RAWPTR(values), cref);
+	return vm_yield_with_cref(th, RARRAY_LENINT(values), RARRAY_CONST_PTR(values), cref);
     }
 }
 
Index: proc.c
===================================================================
--- proc.c	(revision 43042)
+++ proc.c	(revision 43043)
@@ -752,7 +752,7 @@ rb_proc_call(VALUE self, VALUE args) https://github.com/ruby/ruby/blob/trunk/proc.c#L752
     VALUE vret;
     rb_proc_t *proc;
     GetProcPtr(self, proc);
-    vret = rb_vm_invoke_proc(GET_THREAD(), proc, check_argc(RARRAY_LEN(args)), RARRAY_RAWPTR(args), 0);
+    vret = rb_vm_invoke_proc(GET_THREAD(), proc, check_argc(RARRAY_LEN(args)), RARRAY_CONST_PTR(args), 0);
     RB_GC_GUARD(self);
     RB_GC_GUARD(args);
     return vret;
@@ -2429,7 +2429,7 @@ curry(VALUE dummy, VALUE args, int argc, https://github.com/r (... truncated)

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

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