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

ruby-changes:28639

From: ko1 <ko1@a...>
Date: Mon, 13 May 2013 19:49:33 +0900 (JST)
Subject: [ruby-changes:28639] ko1:r40691 (trunk): * include/ruby/ruby.h: constify RBasic::klass and add

ko1	2013-05-13 19:49:11 +0900 (Mon, 13 May 2013)

  New Revision: 40691

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

  Log:
    * include/ruby/ruby.h: constify RBasic::klass and add
      RBASIC_CLASS(obj) macro which returns a class of `obj'.
      This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
    * object.c: add new function rb_obj_reveal().
      This function reveal interal (hidden) object by rb_obj_hide().
      Note that do not change class before and after hiding.
      Only permitted example is:
      klass = RBASIC_CLASS(obj);
      rb_obj_hide(obj);
      ....
      rb_obj_reveal(obj, klass);
      TODO: API design. rb_obj_reveal() should be replaced with others.
      TODO: modify constified variables using cast may be harmful for
      compiler's analysis and optimizaton.
      Any idea to prohibt inserting RBasic::klass directly?
      If rename RBasic::klass and force to use RBASIC_CLASS(obj),
      then all codes such as `RBASIC(obj)->klass' will be
      compilation error. Is it acceptable? (We have similar
      experience at Ruby 1.9,
      for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
    * internal.h: add some macros.
    * RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
      object.
    * RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
    * RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
      without write barrier (planned).
    * RCLASS_SET_SUPER(a, b) set super class of a.
    * array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
      file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
      parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
      string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
      Use above macros and functions to access RBasic::klass.
    * ext/coverage/coverage.c, ext/readline/readline.c,
      ext/socket/ancdata.c, ext/socket/init.c,
    * ext/zlib/zlib.c: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/array.c
    trunk/class.c
    trunk/compile.c
    trunk/encoding.c
    trunk/enum.c
    trunk/error.c
    trunk/eval.c
    trunk/ext/coverage/coverage.c
    trunk/ext/readline/readline.c
    trunk/ext/socket/ancdata.c
    trunk/ext/socket/init.c
    trunk/ext/zlib/zlib.c
    trunk/file.c
    trunk/gc.c
    trunk/hash.c
    trunk/include/ruby/ruby.h
    trunk/internal.h
    trunk/io.c
    trunk/iseq.c
    trunk/marshal.c
    trunk/object.c
    trunk/parse.y
    trunk/proc.c
    trunk/process.c
    trunk/random.c
    trunk/ruby.c
    trunk/sprintf.c
    trunk/string.c
    trunk/thread.c
    trunk/transcode.c
    trunk/vm.c
    trunk/vm_eval.c
    trunk/win32/file.c

Index: array.c
===================================================================
--- array.c	(revision 40690)
+++ array.c	(revision 40691)
@@ -2297,7 +2297,7 @@ rb_ary_sort_bang(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2297
 	struct ary_sort_data data;
 	long len = RARRAY_LEN(ary);
 
-	RBASIC(tmp)->klass = 0;
+	RBASIC_CLEAR_CLASS(tmp);
 	data.ary = tmp;
 	data.opt_methods = 0;
 	data.opt_inited = 0;
@@ -2343,7 +2343,7 @@ rb_ary_sort_bang(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2343
             FL_SET(tmp, FL_FREEZE);
 	}
         /* tmp will be GC'ed. */
-        RBASIC(tmp)->klass = rb_cArray;
+        RBASIC_SET_CLASS_RAW(tmp, rb_cArray); /* rb_cArray must be marked */
     }
     return ary;
 }
@@ -2896,7 +2896,7 @@ rb_ary_slice_bang(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/array.c#L2896
 	}
 	if (len == 0) return rb_ary_new2(0);
 	arg2 = rb_ary_new4(len, RARRAY_PTR(ary)+pos);
-	RBASIC(arg2)->klass = rb_obj_class(ary);
+	RBASIC_SET_CLASS(arg2, rb_obj_class(ary));
 	rb_ary_splice(ary, pos, len, Qundef);
 	return arg2;
     }
@@ -3755,7 +3755,7 @@ ary_tmp_hash_new(void) https://github.com/ruby/ruby/blob/trunk/array.c#L3755
 {
     VALUE hash = rb_hash_new();
 
-    RBASIC(hash)->klass = 0;
+    RBASIC_CLEAR_CLASS(hash);
     return hash;
 }
 
@@ -4192,7 +4192,7 @@ flatten(VALUE ary, int level, int *modif https://github.com/ruby/ruby/blob/trunk/array.c#L4192
 
     st_free_table(memo);
 
-    RBASIC(result)->klass = rb_class_of(ary);
+    RBASIC_SET_CLASS(result, rb_class_of(ary));
     return result;
 }
 
@@ -4461,7 +4461,7 @@ rb_ary_sample(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/array.c#L4461
     else {
 	VALUE *ptr_result;
 	result = rb_ary_new4(len, ptr);
-	RBASIC(result)->klass = 0;
+	RBASIC_CLEAR_CLASS(result);
 	ptr_result = RARRAY_PTR(result);
 	RB_GC_GUARD(ary);
 	for (i=0; i<n; i++) {
@@ -4470,7 +4470,7 @@ rb_ary_sample(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/array.c#L4470
 	    ptr_result[j] = ptr_result[i];
 	    ptr_result[i] = nv;
 	}
-	RBASIC(result)->klass = rb_cArray;
+	RBASIC_SET_CLASS_RAW(result, rb_cArray);
     }
     ARY_SET_LEN(result, n);
 
@@ -4538,9 +4538,9 @@ rb_ary_cycle(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/array.c#L4538
 }
 
 #define tmpbuf(n, size) rb_str_tmp_new((n)*(size))
-#define tmpbuf_discard(s) (rb_str_resize((s), 0L), RBASIC(s)->klass = rb_cString)
+#define tmpbuf_discard(s) (rb_str_resize((s), 0L), RBASIC_SET_CLASS_RAW(s, rb_cString))
 #define tmpary(n) rb_ary_tmp_new(n)
-#define tmpary_discard(a) (ary_discard(a), RBASIC(a)->klass = rb_cArray)
+#define tmpary_discard(a) (ary_discard(a), RBASIC_SET_CLASS_RAW(a, rb_cArray))
 
 /*
  * Recursively compute permutations of +r+ elements of the set
@@ -4679,14 +4679,14 @@ rb_ary_permutation(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/array.c#L4679
 	volatile VALUE t1 = tmpbuf(n,sizeof(char));
 	char *used = (char*)RSTRING_PTR(t1);
 	VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */
-	RBASIC(ary0)->klass = 0;
+	RBASIC_CLEAR_CLASS(ary0);
 
 	MEMZERO(used, char, n); /* initialize array */
 
 	permute0(n, r, p, 0, used, ary0); /* compute and yield permutations */
 	tmpbuf_discard(t0);
 	tmpbuf_discard(t1);
-	RBASIC(ary0)->klass = rb_cArray;
+	RBASIC_SET_CLASS_RAW(ary0, rb_cArray);
     }
     return ary;
 }
@@ -4874,11 +4874,11 @@ rb_ary_repeated_permutation(VALUE ary, V https://github.com/ruby/ruby/blob/trunk/array.c#L4874
 	volatile VALUE t0 = tmpbuf(r, sizeof(long));
 	long *p = (long*)RSTRING_PTR(t0);
 	VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */
-	RBASIC(ary0)->klass = 0;
+	RBASIC_CLEAR_CLASS(ary0);
 
 	rpermute0(n, r, p, 0, ary0); /* compute and yield repeated permutations */
 	tmpbuf_discard(t0);
-	RBASIC(ary0)->klass = rb_cArray;
+	RBASIC_SET_CLASS_RAW(ary0, rb_cArray);
     }
     return ary;
 }
@@ -4971,11 +4971,11 @@ rb_ary_repeated_combination(VALUE ary, V https://github.com/ruby/ruby/blob/trunk/array.c#L4971
 	volatile VALUE t0 = tmpbuf(n, sizeof(long));
 	long *p = (long*)RSTRING_PTR(t0);
 	VALUE ary0 = ary_make_shared_copy(ary); /* private defensive copy of ary */
-	RBASIC(ary0)->klass = 0;
+	RBASIC_CLEAR_CLASS(ary0);
 
 	rcombinate0(len, n, p, 0, n, ary0); /* compute and yield repeated combinations */
 	tmpbuf_discard(t0);
-	RBASIC(ary0)->klass = rb_cArray;
+	RBASIC_SET_CLASS_RAW(ary0, rb_cArray);
     }
     return ary;
 }
@@ -5013,8 +5013,8 @@ rb_ary_product(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/array.c#L5013
     long i,j;
     long resultlen = 1;
 
-    RBASIC(t0)->klass = 0;
-    RBASIC(t1)->klass = 0;
+    RBASIC_CLEAR_CLASS(t0);
+    RBASIC_CLEAR_CLASS(t1);
 
     /* initialize the arrays of arrays */
     ARY_SET_LEN(t0, n);
Index: encoding.c
===================================================================
--- encoding.c	(revision 40690)
+++ encoding.c	(revision 40691)
@@ -1866,7 +1866,7 @@ Init_Encoding(void) https://github.com/ruby/ruby/blob/trunk/encoding.c#L1866
     rb_define_singleton_method(rb_cEncoding, "locale_charmap", rb_locale_charmap, 0);
 
     list = rb_ary_new2(enc_table.count);
-    RBASIC(list)->klass = 0;
+    RBASIC_CLEAR_CLASS(list);
     rb_encoding_list = list;
     rb_gc_register_mark_object(list);
 
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 40690)
+++ include/ruby/ruby.h	(revision 40691)
@@ -683,13 +683,18 @@ VALUE rb_obj_setup(VALUE obj, VALUE klas https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L683
 
 struct RBasic {
     VALUE flags;
-    VALUE klass;
+    const VALUE klass;
 }
 #ifdef __GNUC__
     __attribute__((aligned(sizeof(VALUE))))
 #endif
 ;
 
+VALUE rb_obj_hide(VALUE obj);
+VALUE rb_obj_reveal(VALUE obj, VALUE klass); /* do not use this API to change klass information */
+
+#define RBASIC_CLASS(obj) (RBASIC(obj)->klass)
+
 #define ROBJECT_EMBED_LEN_MAX 3
 struct RObject {
     struct RBasic basic;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40690)
+++ ChangeLog	(revision 40691)
@@ -1,3 +1,47 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon May 13 19:29:54 2013  Koichi Sasada  <ko1@a...>
+
+	* include/ruby/ruby.h: constify RBasic::klass and add
+	  RBASIC_CLASS(obj) macro which returns a class of `obj'.
+	  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
+
+	* object.c: add new function rb_obj_reveal().
+	  This function reveal interal (hidden) object by rb_obj_hide().
+	  Note that do not change class before and after hiding.
+	  Only permitted example is:
+	    klass = RBASIC_CLASS(obj);
+	    rb_obj_hide(obj);
+	    ....
+	    rb_obj_reveal(obj, klass);
+
+	  TODO: API design. rb_obj_reveal() should be replaced with others.
+
+	  TODO: modify constified variables using cast may be harmful for
+	        compiler's analysis and optimizaton.
+	        Any idea to prohibt inserting RBasic::klass directly?
+	        If rename RBasic::klass and force to use RBASIC_CLASS(obj),
+	        then all codes such as `RBASIC(obj)->klass' will be
+	        compilation error. Is it acceptable? (We have similar
+	        experience at Ruby 1.9,
+	        for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
+
+	* internal.h: add some macros.
+	  * RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
+	    object.
+	  * RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
+	  * RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
+	    without write barrier (planned).
+	  * RCLASS_SET_SUPER(a, b) set super class of a.
+
+	* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c, 
+	  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c, 
+	  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
+	  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c: 
+	  Use above macros and functions to access RBasic::klass.
+
+	* ext/coverage/coverage.c, ext/readline/readline.c,
+	  ext/socket/ancdata.c, ext/socket/init.c, 
+	* ext/zlib/zlib.c: ditto.
+
 Mon May 13 18:44:14 2013  Koichi Sasada  <ko1@a...>
 
 	* *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
Index: iseq.c
===================================================================
--- iseq.c	(revision 40690)
+++ iseq.c	(revision 40691)
@@ -246,7 +246,7 @@ rb_iseq_add_mark_object(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L246
     if (!RTEST(iseq->mark_ary)) {
 	iseq->mark_ary = rb_ary_tmp_new(3);
 	OBJ_UNTRUST(iseq->mark_ary);
-	RBASIC(iseq->mark_ary)->klass = 0;
+	RBASIC_CLEAR_CLASS(iseq->mark_ary);
     }
     rb_ary_push(iseq->mark_ary, obj);
 }
Index: enum.c
===================================================================
--- enum.c	(revision 40690)
+++ enum.c	(revision 40691)
@@ -931,7 +931,7 @@ enum_sort_by(VALUE obj) https://github.com/ruby/ruby/blob/trunk/enum.c#L931
     else {
 	ary = rb_ary_new();
     }
-    RBASIC(ary)->klass = 0;
+    RBASIC_CLEAR_CLASS(ary);
     buf = rb_ary_tmp_new(SORT_BY_BUFSIZE*2);
     rb_ary_store(buf, SORT_BY_BUFSIZE*2-1, Qnil);
     memo = NEW_MEMO(0, 0, 0);
@@ -958,7 +958,7 @@ enum_sort_by(VALUE obj) https://github.com/ruby/ruby/blob/trunk/enum.c#L958
 	RARRAY_ASET(ary, i/2, RARRAY_AREF(ary, i));
     }
     rb_ary_resize(ary, RARRAY_LEN(ary)/2);
-    RBASIC(ary)->klass = rb_cArray;
+    RBASIC_SET_CLASS_RAW(ary, rb_cArray);
     OBJ_INFECT(ary, memo);
 
     return ary;
@@ -2309,7 +2309,7 @@ enum_cycle(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/enum.c#L2309
         if (n <= 0) return Qnil;
     }
     ary = rb_ary_new();
-    RBASIC(ary)->klass = 0;
+    RBASIC_CLEAR_CLASS(ary);
     rb_block_call(obj, id_each, 0, 0, cycle_i, ary);
     len = RARRAY_LEN(ary);
     if (len == 0) return Qnil;
Index: string.c
===================================================================
--- string.c	(revision 40690)
+++ string.c	(revision 40691)
@@ -519,7 +519,7 @@ rb_str_conv_enc_opts(VALUE str, rb_encod https://github.com/ruby/ruby/blob/trunk/string.c#L519
     olen = len;
 
     econv_wrapper = rb_obj_alloc(rb_cEncodingConverter);
-    RBASIC(econv_wrapper)->klass = 0;
+    RBASIC_CLEAR_CLASS(econv_wrapper);
     ec = rb_econv_open_opts(from->name, to->name, ecflags, ecopts);
     if (!ec) return str;
     DATA_PTR(econv_wrapper) = ec;
@@ -1446,7 +1446,7 @@ rb_str_associate(VALUE str, VALUE add) https://github.com/ruby/ruby/blob/trunk/string.c#L1446
 	    RESIZE_CAPA(str, RSTRING_LEN(str));
 	}
 	FL_SET(str, STR_ASSOC);
-	RBASIC(add)->klass = 0;
+	RBASIC_CLEAR_CLASS(add);
 	RSTRING(str)->as.heap.aux.shared = add;
     }
 }
@@ -3931,7 +3931,7 @@ str_gsub(int argc, VALUE *argv, VALUE st https://github.com/ruby/ruby/blob/trunk/string.c#L3931
         rb_str_shared_replace(str, dest);
     }
     else {
-	RBASIC(dest)->klass = rb_obj_class(str);
+	RBASIC_SET_CLASS(dest, rb_obj_class(str));
 	OBJ_INFECT(dest, str);
 	str = dest;
     }
Index: object.c
===================================================================
--- object.c	(revision 40690)
+++ object.c	(revision 40691)
@@ -53,7 +53,16 @@ VALUE https://github.com/ruby/ruby/blob/trunk/object.c#L53
 rb_obj_hide(VALUE obj)
 {
     if (!SPECIAL_CONST_P(obj)) {
-	RBASIC(obj)->klass = 0;
+	RBASIC_CLEAR_CLASS(obj);
+    }
+    return obj;
+}
+
+VALUE
+rb_obj_reveal(VALUE obj, VALUE klass)
+{
+    if (!SPECIAL_CONST_P(obj)) {
+	RBASIC_SET_CLASS(obj, klass);
     }
     return obj;
 }
@@ -62,7 +71,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/object.c#L71
 rb_obj_setup(VALUE obj, VALUE klass, VALUE type)
 {
     RBASIC(obj)->flags = type;
-    RBASIC(obj)->klass = klass;
+    RBASIC_SET_CLASS(obj, klass);
     if (rb_safe_level() >= 3) FL_SET((obj), FL_TAINT | FL_UNTRUSTED);
     return obj;
 }
@@ -327,7 +336,7 @@ rb_obj_clone(VALUE obj) https://github.com/ruby/ruby/blob/trunk/object.c#L336
     }
     clone = rb_obj_alloc(rb_obj_class(obj));
     singleton = rb_singleton_class_clone_and_attach(obj, clone);
-    RBASIC(clone)->klass = singleton;
+    RBASIC_SET_CLASS(clone, singleton);
     if (FL_TEST(singleton, FL_SINGLETON)) {
 	rb_singleton_class_attached(singleton, clone);
     }
@@ -1630,7 +1639,7 @@ rb_module_s_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L1639
 {
     VALUE mod = rb_module_new();
 
-    RBASIC(mod)->klass = klass;
+    RBASIC_SET_CLASS(mod, klass);
     return mod;
 }
 
@@ -1723,7 +1732,7 @@ rb_class_initialize(int argc, VALUE *arg https://github.com/ruby/ruby/blob/trunk/object.c#L1732
 	    rb_raise(rb_eTypeError, "can't inherit uninitialized class");
 	}
     }
-    RCLASS_SUPER(klass) = super;
+    RCLASS_SET_SUPER(klass, super);
     rb_make_metaclass(klass, RBASIC(super)->klass);
     rb_class_inherited(super, klass);
     rb_mod_initialize(klass);
@@ -1858,7 +1867,7 @@ rb_class_superclass(VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L1867
 VALUE
 rb_class_get_superclass(VALUE klass)
 {
-    return RCLASS_SUPER(klass);
+    return RCLASS_EXT(klass)->super;
 }
 
 #define id_for_setter(name, type, message) \
Index: io.c
===================================================================
--- io.c	(revision 40690)
+++ io.c	(revision 40691)
@@ -6061,7 +6061,7 @@ rb_io_s_popen(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/io.c#L6061
 	}
 #endif
 	tmp = rb_ary_dup(tmp);
-	RBASIC(tmp)->klass = 0;
+	RBASIC_CLEAR_CLASS(tmp);
 	execarg_obj = rb_execarg_new((int)len, RARRAY_PTR(tmp), FALSE);
 	rb_ary_clear(tmp);
     }
@@ -6091,7 +6091,7 @@ rb_io_s_popen(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/io.c#L6091
 	}
 	return Qnil;
     }
-    RBASIC(port)->klass = klass;
+    RBASIC_SET_CLASS(port, klass);
     if (rb_block_given_p()) {
 	return rb_ensure(rb_yield, port, io_close, port);
     }
@@ -6487,7 +6487,7 @@ io_reopen(VALUE io, VALUE nfile) https://github.com/ruby/ruby/blob/trunk/io.c#L6487
 	rb_io_binmode(io);
     }
 
-    RBASIC(io)->klass = rb_obj_class(nfile);
+    RBASIC_SET_CLASS(io, rb_obj_class(nfile));
     return io;
 }
 
Index: compile.c
===================================================================
--- compile.c	(revision 40690)
+++ compile.c	(revision 40691)
@@ -299,7 +299,7 @@ r_value(VALUE value) https://github.com/ruby/ruby/blob/trunk/compile.c#L299
 #define INIT_ANCHOR(name) \
   (name##_body__.last = &name##_body__.anchor, name = &name##_body__)
 
-#define hide_obj(obj) do {OBJ_FREEZE(obj); RBASIC(obj)->klass = 0;} while (0)
+#define hide_obj(obj) do {OBJ_FREEZE(obj); RBASIC_CLEAR_CLASS(obj);} while (0)
 
 #include "optinsn.inc"
 #if OPT_INSTRUCTIONS_UNIFICATION
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 40690)
+++ vm_eval.c	(revision 40691)
@@ -750,7 +750,7 @@ rb_apply(VALUE recv, ID mid, VALUE args) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L750
     argc = RARRAY_LENINT(args);
     if (argc >= 0x100) {
 	args = rb_ary_subseq(args, 0, argc);
-	RBASIC(args)->klass = 0;
+	RBASIC_CLEAR_CLASS(args);
 	OBJ_FREEZE(args);
 	ret = rb_call(recv, mid, argc, RARRAY_PTR(args), CALL_FCALL);
 	RB_GC_GUARD(args);
Index: proc.c
===================================================================
--- proc.c	(revision 40690)
+++ proc.c	(revision 40691)
@@ -427,7 +427,7 @@ proc_new(VALUE klass, int is_lambda) https://github.com/ruby/ruby/blob/trunk/proc.c#L427
 	}
 	else {
 	    VALUE newprocval = proc_dup(procval);
-	    RBASIC(newprocval)->klass = klass;
+	    RBASIC_SET_CLASS(newprocval, klass);
 	    return newprocval;
 	}
     }
Index: thread.c
===================================================================
--- thread.c	(revision 40690)
+++ thread.c	(revision 40691)
@@ -622,7 +622,7 @@ thread_create_core(VALUE thval, VALUE ar https://github.com/ruby/ruby/blob/trunk/thread.c#L622
     th->pending_interrupt_queue = rb_ary_tmp_new(0);
     th->pending_interrupt_queue_checked = 0;
     th->pending_interrupt_mask_stack = rb_ary_dup(current_th->pending_interrupt_mask_stack);
-    RBASIC(th->pending_interrupt_mask_stack)->klass = 0;
+    RBASIC_CLEAR_CLASS(th->pending_interrupt_mask_stack);
 
     th->interrupt_mask = 0;
 
Index: win32/file.c
===================================================================
--- win32/file.c	(revision 40690)
+++ win32/file.c	(revision 40691)
@@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/win32/file.c#L1
 #include "ruby/ruby.h"
 #include "ruby/encoding.h"
+#include "internal.h"
 #include <winbase.h>
 #include <wchar.h>
 #include <shlwapi.h>
@@ -193,7 +194,7 @@ code_page(rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/win32/file.c#L194
     enc_name = (char *)rb_enc_name(enc);
 
     fake_str.basic.flags = T_STRING|RSTRING_NOEMBED;
-    fake_str.basic.klass = rb_cString;
+    RBASIC_SET_CLASS_RAW((VALUE)&fake_str, rb_cString);
     fake_str.as.heap.len = strlen(enc_name);
     fake_str.as.heap.ptr = enc_name;
     fake_str.as.heap.aux.capa = fake_str.as.heap.len;
Index: sprintf.c
===================================================================
--- sprintf.c	(revision 40690)
+++ sprintf.c	(revision 40691)
@@ -1239,12 +1239,12 @@ rb_enc_vsprintf(rb_encoding *enc, const https://github.com/ruby/ruby/blob/trunk/sprintf.c#L1239
     }
     f._bf._base = (unsigned char *)result;
     f._p = (unsigned char *)RSTRING_PTR(result);
-    RBASIC(result)->klass = 0;
+    RBASIC_CLEAR_CLASS(result);
     f.vwrite = ruby__sfvwrite;
     f.vextra = ruby__sfvextra;
     buffer.value = 0;
     BSD_vfprintf(&f, fmt, ap);
-    RBASIC(result)->klass = rb_cString;
+    RBASIC_SET_CLASS_RAW(result, rb_cString);
     rb_str_resize(result, (char *)f._p - RSTRING_PTR(result));
 #undef f
 
@@ -1298,12 +1298,12 @@ rb_str_vcatf(VALUE str, const char *fmt, https://github.com/ruby/ruby/blob/trunk/sprintf.c#L1298
     f._bf._base = (unsigned char *)str;
     f._p = (unsigned char *)RSTRING_END(str);
     klass = RBASIC(str)->klass;
-    RBASIC(str)->klass = 0;
+    RBASIC_CLEAR_CLASS(str);
     f.vwrite = ruby__sfvwrite;
     f.vextra = ruby__sfvextra;
     buffer.value = 0;
     BSD_vfprintf(&f, fmt, ap);
-    RBASIC(str)->klass = klass;
+    RBASIC_SET_CLASS_RAW(str, klass);
     rb_str_resize(str, (char *)f._p - RSTRING_PTR(str));
 #undef f
 
Index: eval.c
===================================================================
--- eval.c	(revision 40690)
+++ eval.c	(revision 40691)
@@ -1060,7 +1060,7 @@ hidden_identity_hash_new() https://github.com/ruby/ruby/blob/trunk/eval.c#L1060
     VALUE hash = rb_hash_new();
 
     rb_funcall(hash, rb_intern("compare_by_identity"), 0);
-    RBASIC(hash)->klass = 0;  /* hide from ObjectSpace */
+    RBASIC_CLEAR_CLASS(hash); /* hide from ObjectSpace */
     return hash;
 }
 
@@ -1097,7 +1097,7 @@ rb_using_refinement(NODE *cref, VALUE kl https://github.com/ruby/ruby/blob/trunk/eval.c#L1097
     module = RCLASS_SUPER(module);
     while (module && module != klass) {
 	FL_SET(module, RMODULE_IS_OVERLAID);
-	c = RCLASS_SUPER(c) = rb_include_class_new(module, RCLASS_SUPER(c));
+	c = RCLASS_SET_SUPER(c, rb_include_class_new(module, RCLASS_SUPER(c)));
 	RCLASS_REFINED_CLASS(c) = klass;
 	module = RCLASS_SUPER(module);
     }
@@ -1156,8 +1156,7 @@ add_activated_refinement(VALUE activated https://github.com/ruby/ruby/blob/trunk/eval.c#L1156
     refinement = RCLASS_SUPER(refinement);
     while (refinement) {
 	FL_SET(refinement, RMODULE_IS_OVERLAID);
-	c = RCLASS_SUPER(c) =
-	    rb_include_class_new(refinement, RCLASS_SUPER(c));
+	c = RCLASS_SET_SUPER(c, rb_include_class_new(refinement, RCLASS_SUPER(c)));
 	RCLASS_REFINED_CLASS(c) = klass;
 	refinement = RCLASS_SUPER(refinement);
     }
@@ -1210,7 +1209,7 @@ rb_mod_refine(VALUE module, VALUE klass) https://github.com/ruby/ruby/blob/trunk/eval.c#L1209
     refinement = rb_hash_lookup(refinements, klass);
     if (NIL_P(refinement)) {
 	refin (... truncated)

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

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