summaryrefslogtreecommitdiff
path: root/ext/json
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-29 23:12:21 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-29 23:12:21 +0000
commit2a4c4f7b0c147585119036c43c1d04f73621e510 (patch)
treea25d27ffdd53b0b5912e6746131b97a245a3732d /ext/json
parent3d7f8c2320d13fcc0c12e8910d70a812dab2f681 (diff)
* include/ruby/intern.h: declare rb_hash_tbl.
* include/ruby/ruby.h (RHash): delay st_table allocation. rename tbl field to ntbl to detect direct reference to the st_table as a compile error. (RHASH_TBL): abstract accessor defined. (RHASH_ITER_LEV): ditto. (RHASH_IFNONE): ditto. (RHASH_SIZE): ditto. (RHASH_EMPTY_P): ditto. * hash.c: delay st_table allocation. * gc.c: replace tbl by ntbl. * array.c: replace direct field accessor by abstract field accessor such as RHASH(hash)->tbl to RHASH_TBL(hash). * marshal.c: ditto. * insns.def: ditto. * ext/iconv/iconv.c: ditto. * ext/json/ext/generator/generator.c: ditto. * ext/json/ext/parser/parser.c: ditto. * ext/syck/rubyext.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json')
-rw-r--r--ext/json/ext/generator/generator.c8
-rw-r--r--ext/json/ext/parser/parser.c4
2 files changed, 6 insertions, 6 deletions
diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c
index b08455f223..616832c992 100644
--- a/ext/json/ext/generator/generator.c
+++ b/ext/json/ext/generator/generator.c
@@ -86,7 +86,7 @@ static int hash_to_json_state_i(VALUE key, VALUE value, VALUE Vstate)
}
inline static VALUE mHash_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth) {
- long depth, len = RHASH(self)->tbl->num_entries;
+ long depth, len = RHASH_SIZE(self);
VALUE result;
GET_STATE(Vstate);
@@ -140,7 +140,7 @@ static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "02", &Vstate, &Vdepth);
depth = NIL_P(Vdepth) ? 0 : FIX2LONG(Vdepth);
if (NIL_P(Vstate)) {
- long len = RHASH(self)->tbl->num_entries;
+ long len = RHASH_SIZE(self);
result = rb_str_buf_new(len);
rb_str_buf_cat2(result, "{");
rb_hash_foreach(self, hash_to_json_i, result);
@@ -480,7 +480,7 @@ static inline VALUE cState_configure(VALUE self, VALUE opts)
state->object_nl = tmp;
}
tmp = ID2SYM(i_check_circular);
- if (st_lookup(RHASH(opts)->tbl, tmp, 0)) {
+ if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
tmp = rb_hash_aref(opts, ID2SYM(i_check_circular));
state->check_circular = RTEST(tmp);
} else {
@@ -488,7 +488,7 @@ static inline VALUE cState_configure(VALUE self, VALUE opts)
}
tmp = ID2SYM(i_max_nesting);
state->max_nesting = 19;
- if (st_lookup(RHASH(opts)->tbl, tmp, 0)) {
+ if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
VALUE max_nesting = rb_hash_aref(opts, tmp);
if (RTEST(max_nesting)) {
Check_Type(max_nesting, T_FIXNUM);
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
index a1950b067a..a6b7021f7e 100644
--- a/ext/json/ext/parser/parser.c
+++ b/ext/json/ext/parser/parser.c
@@ -1470,7 +1470,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
rb_raise(rb_eArgError, "opts needs to be like a hash");
} else {
VALUE tmp = ID2SYM(i_max_nesting);
- if (st_lookup(RHASH(opts)->tbl, tmp, 0)) {
+ if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
VALUE max_nesting = rb_hash_aref(opts, tmp);
if (RTEST(max_nesting)) {
Check_Type(max_nesting, T_FIXNUM);
@@ -1480,7 +1480,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
}
}
tmp = ID2SYM(i_allow_nan);
- if (st_lookup(RHASH(opts)->tbl, tmp, 0)) {
+ if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
VALUE allow_nan = rb_hash_aref(opts, tmp);
if (RTEST(allow_nan)) json->allow_nan = 1;
}