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

ruby-changes:34426

From: shyouhei <ko1@a...>
Date: Mon, 23 Jun 2014 16:26:23 +0900 (JST)
Subject: [ruby-changes:34426] shyouhei:r46507 (trunk): * include/ruby/ruby.h (struct RHash): no longer. [Feature #9889]

shyouhei	2014-06-23 16:26:03 +0900 (Mon, 23 Jun 2014)

  New Revision: 46507

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

  Log:
    * include/ruby/ruby.h (struct RHash): no longer. [Feature #9889]
    
    * include/ruby/ruby.h (RHASH): ditto.
    
    * include/ruby/ruby.h (RHASH_ITER_LEV): deprecated.  Will be deleted later.
    
    * include/ruby/ruby.h (RHASH_IFNONE): ditto.
    
    * internal.h (struct RHash): moved here.
    
    * internal.h (RHASH): ditto.
    
    * hash.c (rb_hash_iter_lev): do not use this.
    
    * hash.c (rb_hash_ifnone): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/hash.c
    trunk/include/ruby/intern.h
    trunk/include/ruby/ruby.h
    trunk/internal.h
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 46506)
+++ include/ruby/intern.h	(revision 46507)
@@ -508,6 +508,9 @@ struct st_table *rb_hash_tbl(VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L508
 int rb_path_check(const char*);
 int rb_env_path_tainted(void);
 VALUE rb_env_clear(void);
+VALUE rb_hash_size(VALUE);
+DEPRECATED(int rb_hash_iter_lev(VALUE));
+DEPRECATED(VALUE rb_hash_ifnone(VALUE));
 /* io.c */
 #define rb_defout rb_stdout
 RUBY_EXTERN VALUE rb_fs;
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 46506)
+++ include/ruby/ruby.h	(revision 46507)
@@ -919,17 +919,11 @@ struct RRegexp { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L919
 #define RREGEXP_SRC_LEN(r) RSTRING_LEN(RREGEXP(r)->src)
 #define RREGEXP_SRC_END(r) RSTRING_END(RREGEXP(r)->src)
 
-struct RHash {
-    struct RBasic basic;
-    struct st_table *ntbl;      /* possibly 0 */
-    int iter_lev;
-    const VALUE ifnone;
-};
 /* RHASH_TBL allocates st_table if not available. */
 #define RHASH_TBL(h) rb_hash_tbl(h)
-#define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
-#define RHASH_IFNONE(h) (RHASH(h)->ifnone)
-#define RHASH_SIZE(h) (RHASH(h)->ntbl ? (st_index_t)RHASH(h)->ntbl->num_entries : 0)
+#define RHASH_ITER_LEV(h) rb_hash_iter_lev(h)
+#define RHASH_IFNONE(h) rb_hash_ifnone(h)
+#define RHASH_SIZE(h) NUM2SIZET(rb_hash_size(h))
 #define RHASH_EMPTY_P(h) (RHASH_SIZE(h) == 0)
 #define RHASH_SET_IFNONE(h, ifnone) rb_hash_set_ifnone((VALUE)h, ifnone)
 
@@ -1069,7 +1063,6 @@ struct RStruct { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1063
 #define RSTRING(obj) (R_CAST(RString)(obj))
 #define RREGEXP(obj) (R_CAST(RRegexp)(obj))
 #define RARRAY(obj)  (R_CAST(RArray)(obj))
-#define RHASH(obj)   (R_CAST(RHash)(obj))
 #define RDATA(obj)   (R_CAST(RData)(obj))
 #define RTYPEDDATA(obj)   (R_CAST(RTypedData)(obj))
 #define RSTRUCT(obj) (R_CAST(RStruct)(obj))
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46506)
+++ ChangeLog	(revision 46507)
@@ -1,3 +1,21 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jun 23 16:22:50 2014  URABE Shyouhei  <shyouhei@r...>
+
+	* include/ruby/ruby.h (struct RHash): no longer. [Feature #9889]
+
+	* include/ruby/ruby.h (RHASH): ditto.
+
+	* include/ruby/ruby.h (RHASH_ITER_LEV): deprecated.  Will be deleted later.
+
+	* include/ruby/ruby.h (RHASH_IFNONE): ditto.
+
+	* internal.h (struct RHash): moved here.
+
+	* internal.h (RHASH): ditto.
+
+	* hash.c (rb_hash_iter_lev): do not use this.
+
+	* hash.c (rb_hash_ifnone): ditto.
+
 Mon Jun 23 13:30:11 2014  URABE Shyouhei  <shyouhei@r...>
 
 	* include/ruby/ruby.h (struct RComplex): no longer. [Feature #9888]
Index: hash.c
===================================================================
--- hash.c	(revision 46506)
+++ hash.c	(revision 46507)
@@ -70,6 +70,12 @@ static VALUE envtbl; https://github.com/ruby/ruby/blob/trunk/hash.c#L70
 static ID id_hash, id_yield, id_default, id_flatten_bang;
 
 VALUE
+rb_hash_ifnone(VALUE h)
+{
+    return RHASH_IFNONE(h);
+}
+
+VALUE
 rb_hash_set_ifnone(VALUE hash, VALUE ifnone)
 {
     RB_OBJ_WRITE(hash, (&RHASH(hash)->ifnone), ifnone);
@@ -156,6 +162,12 @@ rb_objid_hash(st_index_t index) https://github.com/ruby/ruby/blob/trunk/hash.c#L162
     return hnum;
 }
 
+int
+rb_hash_iter_lev(VALUE h)
+{
+    return RHASH_ITER_LEV(h);
+}
+
 static const struct st_hash_type objhash = {
     rb_any_cmp,
     rb_any_hash,
@@ -1068,8 +1080,6 @@ delete_if_i(VALUE key, VALUE value, VALU https://github.com/ruby/ruby/blob/trunk/hash.c#L1080
     return ST_CONTINUE;
 }
 
-static VALUE rb_hash_size(VALUE hash);
-
 static VALUE
 hash_enum_size(VALUE hash, VALUE args, VALUE eobj)
 {
@@ -1478,7 +1488,7 @@ rb_hash_replace(VALUE hash, VALUE hash2) https://github.com/ruby/ruby/blob/trunk/hash.c#L1488
  *     h.length        #=> 3
  */
 
-static VALUE
+VALUE
 rb_hash_size(VALUE hash)
 {
     return INT2FIX(RHASH_SIZE(hash));
Index: internal.h
===================================================================
--- internal.h	(revision 46506)
+++ internal.h	(revision 46507)
@@ -442,6 +442,24 @@ struct RComplex { https://github.com/ruby/ruby/blob/trunk/internal.h#L442
 #define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
 #endif
 
+struct RHash {
+    struct RBasic basic;
+    struct st_table *ntbl;      /* possibly 0 */
+    int iter_lev;
+    const VALUE ifnone;
+};
+
+#define RHASH(obj)   (R_CAST(RHash)(obj))
+
+#ifdef RHASH_ITER_LEV
+#undef RHASH_ITER_LEV
+#undef RHASH_IFNONE
+#undef RHASH_SIZE
+#define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
+#define RHASH_IFNONE(h) (RHASH(h)->ifnone)
+#define RHASH_SIZE(h) (RHASH(h)->ntbl ? (st_index_t)RHASH(h)->ntbl->num_entries : 0)
+#endif
+
 /* class.c */
 void rb_class_subclass_add(VALUE super, VALUE klass);
 void rb_class_remove_from_super_subclasses(VALUE);

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

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