diff options
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | hash.c | 16 | ||||
-rw-r--r-- | include/ruby/intern.h | 3 | ||||
-rw-r--r-- | include/ruby/ruby.h | 13 | ||||
-rw-r--r-- | internal.h | 18 |
5 files changed, 55 insertions, 13 deletions
@@ -1,3 +1,21 @@ +Mon Jun 23 16:22:50 2014 URABE Shyouhei <shyouhei@ruby-lang.org> + + * 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@ruby-lang.org> * include/ruby/ruby.h (struct RComplex): no longer. [Feature #9888] @@ -70,6 +70,12 @@ static VALUE envtbl; 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) 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, VALUE hash) 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) * h.length #=> 3 */ -static VALUE +VALUE rb_hash_size(VALUE hash) { return INT2FIX(RHASH_SIZE(hash)); diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 486b469cf1..f9858537e1 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -508,6 +508,9 @@ struct st_table *rb_hash_tbl(VALUE); 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; diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 91813821c4..7bb322868e 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -919,17 +919,11 @@ struct RRegexp { #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 { #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)) diff --git a/internal.h b/internal.h index 3f0fd30122..6409da3d1a 100644 --- a/internal.h +++ b/internal.h @@ -442,6 +442,24 @@ struct RComplex { #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); |