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

ruby-changes:19872

From: nobu <ko1@a...>
Date: Sat, 4 Jun 2011 12:49:59 +0900 (JST)
Subject: [ruby-changes:19872] nobu:r31919 (trunk): clone_const_i

nobu	2011-06-04 12:49:50 +0900 (Sat, 04 Jun 2011)

  New Revision: 31919

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

  Log:
    clone_const_i
    
    * class.c (clone_const_i, class_instance_method_list): get rid of
      type-punning function.

  Modified files:
    trunk/class.c

Index: class.c
===================================================================
--- class.c	(revision 31918)
+++ class.c	(revision 31919)
@@ -154,6 +154,12 @@
     return ST_CONTINUE;
 }
 
+static int
+clone_const_i(st_data_t key, st_data_t value, st_data_t data)
+{
+    return clone_const((ID)key, (const rb_const_entry_t *)value, (st_table *)data);
+}
+
 /* :nodoc: */
 VALUE
 rb_mod_init_copy(VALUE clone, VALUE orig)
@@ -181,7 +187,7 @@
 	    rb_free_const_table(RCLASS_CONST_TBL(clone));
 	}
 	RCLASS_CONST_TBL(clone) = st_init_numtable();
-	st_foreach(RCLASS_CONST_TBL(orig), clone_const, (st_data_t)RCLASS_CONST_TBL(clone));
+	st_foreach(RCLASS_CONST_TBL(orig), clone_const_i, (st_data_t)RCLASS_CONST_TBL(clone));
     }
     if (RCLASS_M_TBL(orig)) {
 	if (RCLASS_M_TBL(clone)) {
@@ -234,7 +240,7 @@
 	}
 	if (RCLASS_CONST_TBL(klass)) {
 	    RCLASS_CONST_TBL(clone) = st_init_numtable();
-	    st_foreach(RCLASS_CONST_TBL(klass), clone_const, (st_data_t)RCLASS_CONST_TBL(clone));
+	    st_foreach(RCLASS_CONST_TBL(klass), clone_const_i, (st_data_t)RCLASS_CONST_TBL(clone));
 	}
 	RCLASS_M_TBL(clone) = st_init_numtable();
 	st_foreach(RCLASS_M_TBL(klass), clone_method_i, (st_data_t)clone);
@@ -943,35 +949,37 @@
 }
 
 static int
-ins_methods_i(ID name, long type, VALUE ary)
+ins_methods_i(st_data_t name, st_data_t type, st_data_t ary)
 {
-    return ins_methods_push(name, type, ary, -1); /* everything but private */
+    return ins_methods_push((ID)name, (long)type, (VALUE)ary, -1); /* everything but private */
 }
 
 static int
-ins_methods_prot_i(ID name, long type, VALUE ary)
+ins_methods_prot_i(st_data_t name, st_data_t type, st_data_t ary)
 {
-    return ins_methods_push(name, type, ary, NOEX_PROTECTED);
+    return ins_methods_push((ID)name, (long)type, (VALUE)ary, NOEX_PROTECTED);
 }
 
 static int
-ins_methods_priv_i(ID name, long type, VALUE ary)
+ins_methods_priv_i(st_data_t name, st_data_t type, st_data_t ary)
 {
-    return ins_methods_push(name, type, ary, NOEX_PRIVATE);
+    return ins_methods_push((ID)name, (long)type, (VALUE)ary, NOEX_PRIVATE);
 }
 
 static int
-ins_methods_pub_i(ID name, long type, VALUE ary)
+ins_methods_pub_i(st_data_t name, st_data_t type, st_data_t ary)
 {
-    return ins_methods_push(name, type, ary, NOEX_PUBLIC);
+    return ins_methods_push((ID)name, (long)type, (VALUE)ary, NOEX_PUBLIC);
 }
 
 static int
-method_entry(ID key, const rb_method_entry_t *me, st_table *list)
+method_entry_i(st_data_t key, st_data_t value, st_data_t data)
 {
+    const rb_method_entry_t *me = (const rb_method_entry_t *)value;
+    st_table *list = (st_table *)data;
     long type;
 
-    if (key == ID_ALLOCATOR) {
+    if ((ID)key == ID_ALLOCATOR) {
 	return ST_CONTINUE;
     }
 
@@ -988,7 +996,7 @@
 }
 
 static VALUE
-class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func) (ID, long, VALUE))
+class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func) (st_data_t, st_data_t, st_data_t))
 {
     VALUE ary;
     int recur;
@@ -1005,7 +1013,7 @@
 
     list = st_init_numtable();
     for (; mod; mod = RCLASS_SUPER(mod)) {
-	st_foreach(RCLASS_M_TBL(mod), method_entry, (st_data_t)list);
+	st_foreach(RCLASS_M_TBL(mod), method_entry_i, (st_data_t)list);
 	if (BUILTIN_TYPE(mod) == T_ICLASS) continue;
 	if (obj && FL_TEST(mod, FL_SINGLETON)) continue;
 	if (!recur) break;
@@ -1237,12 +1245,12 @@
     klass = CLASS_OF(obj);
     list = st_init_numtable();
     if (klass && FL_TEST(klass, FL_SINGLETON)) {
-	st_foreach(RCLASS_M_TBL(klass), method_entry, (st_data_t)list);
+	st_foreach(RCLASS_M_TBL(klass), method_entry_i, (st_data_t)list);
 	klass = RCLASS_SUPER(klass);
     }
     if (RTEST(recur)) {
 	while (klass && (FL_TEST(klass, FL_SINGLETON) || TYPE(klass) == T_ICLASS)) {
-	    st_foreach(RCLASS_M_TBL(klass), method_entry, (st_data_t)list);
+	    st_foreach(RCLASS_M_TBL(klass), method_entry_i, (st_data_t)list);
 	    klass = RCLASS_SUPER(klass);
 	}
     }

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

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