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

ruby-changes:17457

From: nobu <ko1@a...>
Date: Tue, 12 Oct 2010 23:49:44 +0900 (JST)
Subject: [ruby-changes:17457] Ruby:r29462 (trunk): * compile.c (iseq_build_body), error.c (set_syserr, get_syserr),

nobu	2010-10-12 23:47:23 +0900 (Tue, 12 Oct 2010)

  New Revision: 29462

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

  Log:
    * compile.c (iseq_build_body), error.c (set_syserr, get_syserr),
      (syserr_initialize), gc.c (define_final, rb_gc_copy_finalizer),
      (run_final), hash.c (rb_hash_aref, rb_hash_lookup2),
      (rb_hash_fetch_m, rb_hash_clear, rb_hash_aset, eql_i),
      iseq.c (iseq_load, iseq_data_to_ary), marshal.c (r_symlink),
      thread.c (rb_thread_local_aref),
      variable.c (generic_ivar_remove, ivar_get, rb_const_get_0),
      (rb_cvar_get), vm.c (rb_vm_check_redefinition_opt_method),
      vm_insnhelper.c (vm_get_ev_const), vm_method.c (remove_method),
      ext/iconv/iconv.c (map_charset): use st_data_t.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/error.c
    trunk/ext/iconv/iconv.c
    trunk/gc.c
    trunk/hash.c
    trunk/iseq.c
    trunk/marshal.c
    trunk/thread.c
    trunk/variable.c
    trunk/vm.c
    trunk/vm_insnhelper.c
    trunk/vm_method.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29461)
+++ ChangeLog	(revision 29462)
@@ -1,5 +1,16 @@
-Tue Oct 12 23:35:37 2010  Nobuyoshi Nakada  <nobu@r...>
+Tue Oct 12 23:47:18 2010  Nobuyoshi Nakada  <nobu@r...>
 
+	* compile.c (iseq_build_body), error.c (set_syserr, get_syserr),
+	  (syserr_initialize), gc.c (define_final, rb_gc_copy_finalizer),
+	  (run_final), hash.c (rb_hash_aref, rb_hash_lookup2),
+	  (rb_hash_fetch_m, rb_hash_clear, rb_hash_aset, eql_i),
+	  iseq.c (iseq_load, iseq_data_to_ary), marshal.c (r_symlink),
+	  thread.c (rb_thread_local_aref),
+	  variable.c (generic_ivar_remove, ivar_get, rb_const_get_0),
+	  (rb_cvar_get), vm.c (rb_vm_check_redefinition_opt_method),
+	  vm_insnhelper.c (vm_get_ev_const), vm_method.c (remove_method),
+	  ext/iconv/iconv.c (map_charset): use st_data_t.
+
 	* compile.c (iseq_build_body), insns.def (getglobal, setglobal),
 	  iseq.c (iseq_load, iseq_data_to_ary), util.c (valid_filename):
 	  use VALUE.
Index: variable.c
===================================================================
--- variable.c	(revision 29461)
+++ variable.c	(revision 29462)
@@ -885,15 +885,16 @@
 generic_ivar_remove(VALUE obj, ID id, st_data_t *valp)
 {
     st_table *tbl;
-    st_data_t data;
+    st_data_t data, key = (st_data_t)id;
     int status;
 
     if (!generic_iv_tbl) return 0;
     if (!st_lookup(generic_iv_tbl, (st_data_t)obj, &data)) return 0;
     tbl = (st_table *)data;
-    status = st_delete(tbl, &id, valp);
+    status = st_delete(tbl, &key, valp);
     if (tbl->num_entries == 0) {
-	st_delete(generic_iv_tbl, &obj, &data);
+	key = (st_data_t)obj;
+	st_delete(generic_iv_tbl, &key, &data);
 	st_free_table((st_table *)data);
     }
     return status;
@@ -1006,8 +1007,8 @@
 	break;
       case T_CLASS:
       case T_MODULE:
-	if (RCLASS_IV_TBL(obj) && st_lookup(RCLASS_IV_TBL(obj), (st_data_t)id, &val))
-	    return val;
+	if (RCLASS_IV_TBL(obj) && st_lookup(RCLASS_IV_TBL(obj), (st_data_t)id, &index))
+	    return (VALUE)index;
 	break;
       default:
 	if (FL_TEST(obj, FL_EXIVAR) || rb_special_const_p(obj))
@@ -1575,7 +1576,9 @@
   retry:
     while (RTEST(tmp)) {
 	VALUE am = 0;
-	while (RCLASS_IV_TBL(tmp) && st_lookup(RCLASS_IV_TBL(tmp), (st_data_t)id, &value)) {
+	st_data_t data;
+	while (RCLASS_IV_TBL(tmp) && st_lookup(RCLASS_IV_TBL(tmp), (st_data_t)id, &data)) {
+	    value = (VALUE)data;
 	    if (value == Qundef) {
 		if (am == tmp) break;
 		am = tmp;
@@ -1937,7 +1940,8 @@
 VALUE
 rb_cvar_get(VALUE klass, ID id)
 {
-    VALUE value, tmp, front = 0, target = 0;
+    VALUE tmp, front = 0, target = 0;
+    st_data_t value;
 
     tmp = klass;
     CVAR_LOOKUP(&value, {if (!front) front = klass; target = klass;});
@@ -1957,7 +1961,7 @@
 	    st_delete(RCLASS_IV_TBL(front),&did,0);
 	}
     }
-    return value;
+    return (VALUE)value;
 }
 
 VALUE
Index: iseq.c
===================================================================
--- iseq.c	(revision 29461)
+++ iseq.c	(revision 29462)
@@ -446,7 +446,7 @@
     VALUE name, filename, filepath, line_no;
     VALUE type, body, locals, args, exception;
 
-    VALUE iseq_type;
+    st_data_t iseq_type;
     struct st_table *type_map = 0;
     rb_iseq_t *iseq;
     rb_compile_option_t option;
@@ -1304,7 +1304,7 @@
 
     for (i=0, pos=0; i<RARRAY_LEN(nbody); i++) {
 	VALUE ary = RARRAY_PTR(nbody)[i];
-	VALUE label;
+	st_data_t label;
 
 	if (st_lookup(labels_table, pos, &label)) {
 	    rb_ary_push(body, (VALUE)label);
Index: compile.c
===================================================================
--- compile.c	(revision 29461)
+++ compile.c	(revision 29462)
@@ -5257,11 +5257,11 @@
 	else if (TYPE(obj) == T_ARRAY) {
 	    VALUE *argv = 0;
 	    int argc = RARRAY_LENINT(obj) - 1;
-	    VALUE insn_id;
+	    st_data_t insn_id;
 	    VALUE insn;
 
 	    insn = (argc < 0) ? Qnil : RARRAY_PTR(obj)[0];
-	    if (st_lookup(insn_table, insn, &insn_id) == 0) {
+	    if (st_lookup(insn_table, (st_data_t)insn, &insn_id) == 0) {
 		/* TODO: exception */
 		RB_GC_GUARD(insn) = rb_inspect(insn);
 		rb_compile_error(RSTRING_PTR(iseq->filename), line_no,
Index: thread.c
===================================================================
--- thread.c	(revision 29461)
+++ thread.c	(revision 29462)
@@ -1986,7 +1986,7 @@
 rb_thread_local_aref(VALUE thread, ID id)
 {
     rb_thread_t *th;
-    VALUE val;
+    st_data_t val;
 
     GetThreadPtr(thread, th);
     if (rb_safe_level() >= 4 && th != GET_THREAD()) {
@@ -1996,7 +1996,7 @@
 	return Qnil;
     }
     if (st_lookup(th->local_storage, id, &val)) {
-	return val;
+	return (VALUE)val;
     }
     return Qnil;
 }
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 29461)
+++ vm_method.c	(revision 29462)
@@ -454,7 +454,7 @@
 static void
 remove_method(VALUE klass, ID mid)
 {
-    st_data_t data;
+    st_data_t key, data;
     rb_method_entry_t *me = 0;
 
     if (klass == rb_cObject) {
@@ -475,7 +475,8 @@
 	rb_name_error(mid, "method `%s' not defined in %s",
 		      rb_id2name(mid), rb_class2name(klass));
     }
-    st_delete(RCLASS_M_TBL(klass), &mid, &data);
+    key = (st_data_t)mid;
+    st_delete(RCLASS_M_TBL(klass), &key, &data);
 
     rb_vm_check_redefinition_opt_method(me);
     rb_clear_cache_for_undef(klass, mid);
Index: gc.c
===================================================================
--- gc.c	(revision 29461)
+++ gc.c	(revision 29462)
@@ -2699,6 +2699,7 @@
 {
     rb_objspace_t *objspace = &rb_objspace;
     VALUE obj, block, table;
+    st_data_t data;
 
     rb_scan_args(argc, argv, "11", &obj, &block);
     if (OBJ_FROZEN(obj)) rb_error_frozen("object");
@@ -2721,7 +2722,8 @@
     if (!finalizer_table) {
 	finalizer_table = st_init_numtable();
     }
-    if (st_lookup(finalizer_table, obj, &table)) {
+    if (st_lookup(finalizer_table, obj, &data)) {
+	table = (VALUE)data;
 	rb_ary_push(table, block);
     }
     else {
@@ -2737,10 +2739,12 @@
 {
     rb_objspace_t *objspace = &rb_objspace;
     VALUE table;
+    st_data_t data;
 
     if (!finalizer_table) return;
     if (!FL_TEST(obj, FL_FINALIZE)) return;
-    if (st_lookup(finalizer_table, obj, &table)) {
+    if (st_lookup(finalizer_table, obj, &data)) {
+	table = (VALUE)data;
 	st_insert(finalizer_table, dest, table);
     }
     FL_SET(dest, FL_FINALIZE);
@@ -2777,8 +2781,9 @@
 static void
 run_final(rb_objspace_t *objspace, VALUE obj)
 {
-    VALUE table, objid;
+    VALUE objid;
     RUBY_DATA_FUNC free_func = 0;
+    st_data_t key, table;
 
     objid = rb_obj_id(obj);	/* make obj into id */
     RBASIC(obj)->klass = 0;
@@ -2793,9 +2798,10 @@
 	(*free_func)(DATA_PTR(obj));
     }
 
+    key = (st_data_t)obj;
     if (finalizer_table &&
-	st_delete(finalizer_table, (st_data_t*)&obj, &table)) {
-	run_finalizer(objspace, obj, objid, table);
+	st_delete(finalizer_table, &key, &table)) {
+	run_finalizer(objspace, obj, objid, (VALUE)table);
     }
 }
 
Index: ext/iconv/iconv.c
===================================================================
--- ext/iconv/iconv.c	(revision 29461)
+++ ext/iconv/iconv.c	(revision 29462)
@@ -164,10 +164,11 @@
     VALUE val = StringValue(*code);
 
     if (RHASH_SIZE(charset_map)) {
+	st_data_t data;
 	VALUE key = rb_funcall2(val, rb_intern("downcase"), 0, 0);
 	StringValuePtr(key);
-	if (st_lookup(RHASH_TBL(charset_map), key, &val)) {
-	    *code = val;
+	if (st_lookup(RHASH_TBL(charset_map), key, &data)) {
+	    *code = (VALUE)data;
 	}
     }
     return StringValuePtr(*code);
Index: hash.c
===================================================================
--- hash.c	(revision 29461)
+++ hash.c	(revision 29462)
@@ -506,23 +506,23 @@
 VALUE
 rb_hash_aref(VALUE hash, VALUE key)
 {
-    VALUE val;
+    st_data_t val;
 
     if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
 	return rb_funcall(hash, id_default, 1, key);
     }
-    return val;
+    return (VALUE)val;
 }
 
 VALUE
 rb_hash_lookup2(VALUE hash, VALUE key, VALUE def)
 {
-    VALUE val;
+    st_data_t val;
 
     if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
 	return def; /* without Hash#default */
     }
-    return val;
+    return (VALUE)val;
 }
 
 VALUE
@@ -564,7 +564,7 @@
 rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash)
 {
     VALUE key, if_none;
-    VALUE val;
+    st_data_t val;
     long block_given;
 
     rb_scan_args(argc, argv, "11", &key, &if_none);
@@ -584,7 +584,7 @@
 	}
 	return if_none;
     }
-    return val;
+    return (VALUE)val;
 }
 
 VALUE
@@ -1094,6 +1094,12 @@
     return hash;
 }
 
+static st_data_t
+copy_str_key(st_data_t str)
+{
+    return (st_data_t)rb_str_new4((VALUE)str);
+}
+
 /*
  *  call-seq:
  *     hsh[key] = value        -> value
@@ -1121,7 +1127,7 @@
 	st_insert(RHASH(hash)->ntbl, key, val);
     }
     else {
-	st_insert2(RHASH(hash)->ntbl, key, val, rb_str_new4);
+	st_insert2(RHASH(hash)->ntbl, key, val, copy_str_key);
     }
     return val;
 }
@@ -1548,14 +1554,14 @@
 eql_i(VALUE key, VALUE val1, VALUE arg)
 {
     struct equal_data *data = (struct equal_data *)arg;
-    VALUE val2;
+    st_data_t val2;
 
     if (key == Qundef) return ST_CONTINUE;
     if (!st_lookup(data->tbl, key, &val2)) {
 	data->result = Qfalse;
 	return ST_STOP;
     }
-    if (!(data->eql ? rb_eql(val1, val2) : (int)rb_equal(val1, val2))) {
+    if (!(data->eql ? rb_eql(val1, (VALUE)val2) : (int)rb_equal(val1, (VALUE)val2))) {
 	data->result = Qfalse;
 	return ST_STOP;
     }
Index: error.c
===================================================================
--- error.c	(revision 29461)
+++ error.c	(revision 29462)
@@ -980,7 +980,7 @@
 static VALUE
 set_syserr(int n, const char *name)
 {
-    VALUE error;
+    st_data_t error;
 
     if (!st_lookup(syserr_tbl, n, &error)) {
 	error = rb_define_class_under(rb_mErrno, name, rb_eSystemCallError);
@@ -996,7 +996,7 @@
 static VALUE
 get_syserr(int n)
 {
-    VALUE error;
+    st_data_t error;
 
     if (!st_lookup(syserr_tbl, n, &error)) {
 	char name[8];	/* some Windows' errno have 5 digits. */
@@ -1029,11 +1029,13 @@
     VALUE klass = rb_obj_class(self);
 
     if (klass == rb_eSystemCallError) {
+	st_data_t data = (st_data_t)klass;
 	rb_scan_args(argc, argv, "11", &mesg, &error);
 	if (argc == 1 && FIXNUM_P(mesg)) {
 	    error = mesg; mesg = Qnil;
 	}
-	if (!NIL_P(error) && st_lookup(syserr_tbl, NUM2LONG(error), &klass)) {
+	if (!NIL_P(error) && st_lookup(syserr_tbl, NUM2LONG(error), &data)) {
+	    klass = (VALUE)data;
 	    /* change class */
 	    if (TYPE(self) != T_OBJECT) { /* insurance to avoid type crash */
 		rb_raise(rb_eTypeError, "invalid instance type");
Index: vm.c
===================================================================
--- vm.c	(revision 29461)
+++ vm.c	(revision 29462)
@@ -948,7 +948,7 @@
 static void
 rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me)
 {
-    VALUE bop;
+    st_data_t bop;
     if (!me->def || me->def->type == VM_METHOD_TYPE_CFUNC) {
 	if (st_lookup(vm_opt_method_table, (st_data_t)me, &bop)) {
 	    ruby_vm_redefined_flag[bop] = 1;
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 29461)
+++ vm_insnhelper.c	(revision 29462)
@@ -1167,9 +1167,11 @@
 
 	    if (!NIL_P(klass)) {
 		VALUE am = 0;
+		st_data_t data;
 	      search_continue:
 		if (RCLASS_IV_TBL(klass) &&
-		    st_lookup(RCLASS_IV_TBL(klass), id, &val)) {
+		    st_lookup(RCLASS_IV_TBL(klass), id, &data)) {
+		    val = (st_data_t)data;
 		    if (val == Qundef) {
 			if (am == klass) break;
 			am = klass;
Index: marshal.c
===================================================================
--- marshal.c	(revision 29461)
+++ marshal.c	(revision 29462)
@@ -1137,11 +1137,11 @@
 static ID
 r_symlink(struct load_arg *arg)
 {
-    ID id;
+    st_data_t id;
     long num = r_long(arg);
 
     if (st_lookup(arg->symbols, num, &id)) {
-	return id;
+	return (ID)id;
     }
     rb_raise(rb_eArgError, "bad symbol");
 }

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

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