diff options
author | Florian Frank <flori@ping.de> | 2010-02-27 20:42:42 +0100 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2010-02-27 20:42:42 +0100 |
commit | 98a6817eec97852895208513311dc5d5af1c9c05 (patch) | |
tree | 716d4005dbdb16f05b1dbb9b743a691f10f5e53f /ext/json | |
parent | 77de417b6c27884d220540e93c1aae4263da0b06 (diff) | |
download | json-98a6817eec97852895208513311dc5d5af1c9c05.tar.gz |
Compatibility to Rubiniusv1.2.2
Bumped the version number to 1.2.2 and fixed some tests, too.
Diffstat (limited to 'ext/json')
-rw-r--r-- | ext/json/ext/generator/generator.c | 13 | ||||
-rw-r--r-- | ext/json/ext/parser/parser.c | 173 | ||||
-rw-r--r-- | ext/json/ext/parser/parser.rl | 25 |
3 files changed, 98 insertions, 113 deletions
diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c index 558f28d..40daf09 100644 --- a/ext/json/ext/generator/generator.c +++ b/ext/json/ext/generator/generator.c @@ -9,10 +9,6 @@ #include "unicode.h" #include <math.h> -#ifndef RHASH_TBL -#define RHASH_TBL(hsh) (RHASH(hsh)->tbl) -#endif - #ifndef RHASH_SIZE #define RHASH_SIZE(hsh) (RHASH(hsh)->tbl->num_entries) #endif @@ -21,6 +17,8 @@ #define RFLOAT_VALUE(val) (RFLOAT(val)->value) #endif +#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key)) + #ifdef HAVE_RUBY_ENCODING_H #include "ruby/encoding.h" #define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding()) @@ -43,7 +41,7 @@ static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject, static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before, i_object_nl, i_array_nl, i_check_circular, i_max_nesting, - i_allow_nan, i_pack, i_unpack, i_create_id, i_extend; + i_allow_nan, i_pack, i_unpack, i_create_id, i_extend, i_key_p; typedef struct JSON_Generator_StateStruct { VALUE indent; @@ -543,7 +541,7 @@ static VALUE cState_configure(VALUE self, VALUE opts) state->object_nl = tmp; } tmp = ID2SYM(i_check_circular); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { tmp = rb_hash_aref(opts, ID2SYM(i_check_circular)); state->check_circular = RTEST(tmp); } else { @@ -551,7 +549,7 @@ static VALUE cState_configure(VALUE self, VALUE opts) } tmp = ID2SYM(i_max_nesting); state->max_nesting = 19; - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { VALUE max_nesting = rb_hash_aref(opts, tmp); if (RTEST(max_nesting)) { Check_Type(max_nesting, T_FIXNUM); @@ -927,6 +925,7 @@ void Init_generator() i_unpack = rb_intern("unpack"); i_create_id = rb_intern("create_id"); i_extend = rb_intern("extend"); + i_key_p = rb_intern("key?"); #ifdef HAVE_RUBY_ENCODING_H mEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8")); i_encoding = rb_intern("encoding"); diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index a0a56ea..96530fb 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -5,18 +5,10 @@ #if HAVE_RE_H #include "re.h" #endif -#if HAVE_RUBY_ST_H -#include "ruby/st.h" -#endif -#if HAVE_ST_H -#include "st.h" -#endif #define EVIL 0x666 -#ifndef RHASH_TBL -#define RHASH_TBL(hsh) (RHASH(hsh)->tbl) -#endif +#define option_given_p(opts, key) RTEST(rb_funcall((opts), i_key_p, 1, (key))) #ifdef HAVE_RUBY_ENCODING_H #include "ruby/encoding.h" @@ -34,7 +26,7 @@ static VALUE CNaN, CInfinity, CMinusInfinity; static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_object_class, - i_array_class; + i_array_class, i_key_p; #define MinusInfinity "-Infinity" @@ -65,11 +57,11 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul Data_Get_Struct(self, JSON_Parser, json); -#line 91 "parser.rl" +#line 83 "parser.rl" -#line 73 "parser.c" +#line 65 "parser.c" static const int JSON_object_start = 1; static const int JSON_object_first_final = 27; static const int JSON_object_error = 0; @@ -77,7 +69,7 @@ static const int JSON_object_error = 0; static const int JSON_object_en_main = 1; -#line 126 "parser.rl" +#line 118 "parser.rl" static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -93,14 +85,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class); -#line 97 "parser.c" +#line 89 "parser.c" { cs = JSON_object_start; } -#line 141 "parser.rl" +#line 133 "parser.rl" -#line 104 "parser.c" +#line 96 "parser.c" { if ( p == pe ) goto _test_eof; @@ -128,7 +120,7 @@ case 2: goto st2; goto st0; tr2: -#line 110 "parser.rl" +#line 102 "parser.rl" { json->parsing_name = 1; char *np = JSON_parse_string(json, p, pe, &last_name); @@ -140,7 +132,7 @@ st3: if ( ++p == pe ) goto _test_eof3; case 3: -#line 144 "parser.c" +#line 136 "parser.c" switch( (*p) ) { case 13: goto st3; case 32: goto st3; @@ -207,7 +199,7 @@ case 8: goto st8; goto st0; tr11: -#line 99 "parser.rl" +#line 91 "parser.rl" { VALUE v = Qnil; char *np = JSON_parse_value(json, p, pe, &v); @@ -223,7 +215,7 @@ st9: if ( ++p == pe ) goto _test_eof9; case 9: -#line 227 "parser.c" +#line 219 "parser.c" switch( (*p) ) { case 13: goto st9; case 32: goto st9; @@ -312,14 +304,14 @@ case 18: goto st9; goto st18; tr4: -#line 117 "parser.rl" +#line 109 "parser.rl" { p--; {p++; cs = 27; goto _out;} } goto st27; st27: if ( ++p == pe ) goto _test_eof27; case 27: -#line 323 "parser.c" +#line 315 "parser.c" goto st0; st19: if ( ++p == pe ) @@ -417,7 +409,7 @@ case 26: _out: {} } -#line 142 "parser.rl" +#line 134 "parser.rl" if (cs >= JSON_object_first_final) { if (RTEST(json->create_id)) { @@ -436,7 +428,7 @@ case 26: } -#line 440 "parser.c" +#line 432 "parser.c" static const int JSON_value_start = 1; static const int JSON_value_first_final = 21; static const int JSON_value_error = 0; @@ -444,7 +436,7 @@ static const int JSON_value_error = 0; static const int JSON_value_en_main = 1; -#line 240 "parser.rl" +#line 232 "parser.rl" static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -452,14 +444,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul int cs = EVIL; -#line 456 "parser.c" +#line 448 "parser.c" { cs = JSON_value_start; } -#line 247 "parser.rl" +#line 239 "parser.rl" -#line 463 "parser.c" +#line 455 "parser.c" { if ( p == pe ) goto _test_eof; @@ -484,14 +476,14 @@ st0: cs = 0; goto _out; tr0: -#line 188 "parser.rl" +#line 180 "parser.rl" { char *np = JSON_parse_string(json, p, pe, result); if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;} } goto st21; tr2: -#line 193 "parser.rl" +#line 185 "parser.rl" { char *np; if(pe > p + 9 && !strncmp(MinusInfinity, p, 9)) { @@ -511,7 +503,7 @@ tr2: } goto st21; tr5: -#line 211 "parser.rl" +#line 203 "parser.rl" { char *np; json->current_nesting++; @@ -521,7 +513,7 @@ tr5: } goto st21; tr9: -#line 219 "parser.rl" +#line 211 "parser.rl" { char *np; json->current_nesting++; @@ -531,7 +523,7 @@ tr9: } goto st21; tr16: -#line 181 "parser.rl" +#line 173 "parser.rl" { if (json->allow_nan) { *result = CInfinity; @@ -541,7 +533,7 @@ tr16: } goto st21; tr18: -#line 174 "parser.rl" +#line 166 "parser.rl" { if (json->allow_nan) { *result = CNaN; @@ -551,19 +543,19 @@ tr18: } goto st21; tr22: -#line 168 "parser.rl" +#line 160 "parser.rl" { *result = Qfalse; } goto st21; tr25: -#line 165 "parser.rl" +#line 157 "parser.rl" { *result = Qnil; } goto st21; tr28: -#line 171 "parser.rl" +#line 163 "parser.rl" { *result = Qtrue; } @@ -572,9 +564,9 @@ st21: if ( ++p == pe ) goto _test_eof21; case 21: -#line 227 "parser.rl" +#line 219 "parser.rl" { p--; {p++; cs = 21; goto _out;} } -#line 578 "parser.c" +#line 570 "parser.c" goto st0; st2: if ( ++p == pe ) @@ -735,7 +727,7 @@ case 20: _out: {} } -#line 248 "parser.rl" +#line 240 "parser.rl" if (cs >= JSON_value_first_final) { return p; @@ -745,7 +737,7 @@ case 20: } -#line 749 "parser.c" +#line 741 "parser.c" static const int JSON_integer_start = 1; static const int JSON_integer_first_final = 5; static const int JSON_integer_error = 0; @@ -753,7 +745,7 @@ static const int JSON_integer_error = 0; static const int JSON_integer_en_main = 1; -#line 264 "parser.rl" +#line 256 "parser.rl" static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -761,15 +753,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res int cs = EVIL; -#line 765 "parser.c" +#line 757 "parser.c" { cs = JSON_integer_start; } -#line 271 "parser.rl" +#line 263 "parser.rl" json->memo = p; -#line 773 "parser.c" +#line 765 "parser.c" { if ( p == pe ) goto _test_eof; @@ -803,14 +795,14 @@ case 3: goto st0; goto tr4; tr4: -#line 261 "parser.rl" +#line 253 "parser.rl" { p--; {p++; cs = 5; goto _out;} } goto st5; st5: if ( ++p == pe ) goto _test_eof5; case 5: -#line 814 "parser.c" +#line 806 "parser.c" goto st0; st4: if ( ++p == pe ) @@ -829,7 +821,7 @@ case 4: _out: {} } -#line 273 "parser.rl" +#line 265 "parser.rl" if (cs >= JSON_integer_first_final) { long len = p - json->memo; @@ -841,7 +833,7 @@ case 4: } -#line 845 "parser.c" +#line 837 "parser.c" static const int JSON_float_start = 1; static const int JSON_float_first_final = 10; static const int JSON_float_error = 0; @@ -849,7 +841,7 @@ static const int JSON_float_error = 0; static const int JSON_float_en_main = 1; -#line 295 "parser.rl" +#line 287 "parser.rl" static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -857,15 +849,15 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul int cs = EVIL; -#line 861 "parser.c" +#line 853 "parser.c" { cs = JSON_float_start; } -#line 302 "parser.rl" +#line 294 "parser.rl" json->memo = p; -#line 869 "parser.c" +#line 861 "parser.c" { if ( p == pe ) goto _test_eof; @@ -923,14 +915,14 @@ case 5: goto st0; goto tr7; tr7: -#line 289 "parser.rl" +#line 281 "parser.rl" { p--; {p++; cs = 10; goto _out;} } goto st10; st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 934 "parser.c" +#line 926 "parser.c" goto st0; st6: if ( ++p == pe ) @@ -991,7 +983,7 @@ case 9: _out: {} } -#line 304 "parser.rl" +#line 296 "parser.rl" if (cs >= JSON_float_first_final) { long len = p - json->memo; @@ -1004,7 +996,7 @@ case 9: -#line 1008 "parser.c" +#line 1000 "parser.c" static const int JSON_array_start = 1; static const int JSON_array_first_final = 17; static const int JSON_array_error = 0; @@ -1012,7 +1004,7 @@ static const int JSON_array_error = 0; static const int JSON_array_en_main = 1; -#line 340 "parser.rl" +#line 332 "parser.rl" static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -1026,14 +1018,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class); -#line 1030 "parser.c" +#line 1022 "parser.c" { cs = JSON_array_start; } -#line 353 "parser.rl" +#line 345 "parser.rl" -#line 1037 "parser.c" +#line 1029 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1072,7 +1064,7 @@ case 2: goto st2; goto st0; tr2: -#line 321 "parser.rl" +#line 313 "parser.rl" { VALUE v = Qnil; char *np = JSON_parse_value(json, p, pe, &v); @@ -1088,7 +1080,7 @@ st3: if ( ++p == pe ) goto _test_eof3; case 3: -#line 1092 "parser.c" +#line 1084 "parser.c" switch( (*p) ) { case 13: goto st3; case 32: goto st3; @@ -1188,14 +1180,14 @@ case 12: goto st3; goto st12; tr4: -#line 332 "parser.rl" +#line 324 "parser.rl" { p--; {p++; cs = 17; goto _out;} } goto st17; st17: if ( ++p == pe ) goto _test_eof17; case 17: -#line 1199 "parser.c" +#line 1191 "parser.c" goto st0; st13: if ( ++p == pe ) @@ -1251,7 +1243,7 @@ case 16: _out: {} } -#line 354 "parser.rl" +#line 346 "parser.rl" if(cs >= JSON_array_first_final) { return p + 1; @@ -1317,7 +1309,7 @@ static VALUE json_string_unescape(char *p, char *pe) } -#line 1321 "parser.c" +#line 1313 "parser.c" static const int JSON_string_start = 1; static const int JSON_string_first_final = 8; static const int JSON_string_error = 0; @@ -1325,7 +1317,7 @@ static const int JSON_string_error = 0; static const int JSON_string_en_main = 1; -#line 438 "parser.rl" +#line 430 "parser.rl" static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -1334,15 +1326,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu *result = rb_str_new("", 0); -#line 1338 "parser.c" +#line 1330 "parser.c" { cs = JSON_string_start; } -#line 446 "parser.rl" +#line 438 "parser.rl" json->memo = p; -#line 1346 "parser.c" +#line 1338 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1367,7 +1359,7 @@ case 2: goto st0; goto st2; tr2: -#line 424 "parser.rl" +#line 416 "parser.rl" { *result = json_string_unescape(json->memo + 1, p); if (NIL_P(*result)) { @@ -1378,14 +1370,14 @@ tr2: {p = (( p + 1))-1;} } } -#line 435 "parser.rl" +#line 427 "parser.rl" { p--; {p++; cs = 8; goto _out;} } goto st8; st8: if ( ++p == pe ) goto _test_eof8; case 8: -#line 1389 "parser.c" +#line 1381 "parser.c" goto st0; st3: if ( ++p == pe ) @@ -1461,7 +1453,7 @@ case 7: _out: {} } -#line 448 "parser.rl" +#line 440 "parser.rl" if (json->symbolize_names && json->parsing_name) { *result = rb_str_intern(*result); @@ -1475,7 +1467,7 @@ case 7: -#line 1479 "parser.c" +#line 1471 "parser.c" static const int JSON_start = 1; static const int JSON_first_final = 10; static const int JSON_error = 0; @@ -1483,7 +1475,7 @@ static const int JSON_error = 0; static const int JSON_en_main = 1; -#line 485 "parser.rl" +#line 477 "parser.rl" /* @@ -1588,7 +1580,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_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { VALUE max_nesting = rb_hash_aref(opts, tmp); if (RTEST(max_nesting)) { Check_Type(max_nesting, T_FIXNUM); @@ -1600,21 +1592,21 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) json->max_nesting = 19; } tmp = ID2SYM(i_allow_nan); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { VALUE allow_nan = rb_hash_aref(opts, tmp); json->allow_nan = RTEST(allow_nan) ? 1 : 0; } else { json->allow_nan = 0; } tmp = ID2SYM(i_symbolize_names); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { VALUE symbolize_names = rb_hash_aref(opts, tmp); json->symbolize_names = RTEST(symbolize_names) ? 1 : 0; } else { json->symbolize_names = 0; } tmp = ID2SYM(i_create_additions); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { VALUE create_additions = rb_hash_aref(opts, tmp); if (RTEST(create_additions)) { json->create_id = rb_funcall(mJSON, i_create_id, 0); @@ -1625,13 +1617,13 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) json->create_id = rb_funcall(mJSON, i_create_id, 0); } tmp = ID2SYM(i_object_class); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { json->object_class = rb_hash_aref(opts, tmp); } else { json->object_class = Qnil; } tmp = ID2SYM(i_array_class); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { json->array_class = rb_hash_aref(opts, tmp); } else { json->array_class = Qnil; @@ -1665,16 +1657,16 @@ static VALUE cParser_parse(VALUE self) GET_STRUCT; -#line 1669 "parser.c" +#line 1661 "parser.c" { cs = JSON_start; } -#line 666 "parser.rl" +#line 658 "parser.rl" p = json->source; pe = p + json->len; -#line 1678 "parser.c" +#line 1670 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1730,7 +1722,7 @@ case 5: goto st1; goto st5; tr3: -#line 474 "parser.rl" +#line 466 "parser.rl" { char *np; json->current_nesting = 1; @@ -1739,7 +1731,7 @@ tr3: } goto st10; tr4: -#line 467 "parser.rl" +#line 459 "parser.rl" { char *np; json->current_nesting = 1; @@ -1751,7 +1743,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 1755 "parser.c" +#line 1747 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -1808,7 +1800,7 @@ case 9: _out: {} } -#line 669 "parser.rl" +#line 661 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; @@ -1882,6 +1874,7 @@ void Init_parser() i_symbolize_names = rb_intern("symbolize_names"); i_object_class = rb_intern("object_class"); i_array_class = rb_intern("array_class"); + i_key_p = rb_intern("key?"); #ifdef HAVE_RUBY_ENCODING_H mEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8")); mEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be")); diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl index b3e0cd5..f247b07 100644 --- a/ext/json/ext/parser/parser.rl +++ b/ext/json/ext/parser/parser.rl @@ -3,18 +3,10 @@ #if HAVE_RE_H #include "re.h" #endif -#if HAVE_RUBY_ST_H -#include "ruby/st.h" -#endif -#if HAVE_ST_H -#include "st.h" -#endif #define EVIL 0x666 -#ifndef RHASH_TBL -#define RHASH_TBL(hsh) (RHASH(hsh)->tbl) -#endif +#define option_given_p(opts, key) RTEST(rb_funcall((opts), i_key_p, 1, (key))) #ifdef HAVE_RUBY_ENCODING_H #include "ruby/encoding.h" @@ -32,7 +24,7 @@ static VALUE CNaN, CInfinity, CMinusInfinity; static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_object_class, - i_array_class; + i_array_class, i_key_p; #define MinusInfinity "-Infinity" @@ -586,7 +578,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_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { VALUE max_nesting = rb_hash_aref(opts, tmp); if (RTEST(max_nesting)) { Check_Type(max_nesting, T_FIXNUM); @@ -598,21 +590,21 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) json->max_nesting = 19; } tmp = ID2SYM(i_allow_nan); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { VALUE allow_nan = rb_hash_aref(opts, tmp); json->allow_nan = RTEST(allow_nan) ? 1 : 0; } else { json->allow_nan = 0; } tmp = ID2SYM(i_symbolize_names); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { VALUE symbolize_names = rb_hash_aref(opts, tmp); json->symbolize_names = RTEST(symbolize_names) ? 1 : 0; } else { json->symbolize_names = 0; } tmp = ID2SYM(i_create_additions); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { VALUE create_additions = rb_hash_aref(opts, tmp); if (RTEST(create_additions)) { json->create_id = rb_funcall(mJSON, i_create_id, 0); @@ -623,13 +615,13 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) json->create_id = rb_funcall(mJSON, i_create_id, 0); } tmp = ID2SYM(i_object_class); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { json->object_class = rb_hash_aref(opts, tmp); } else { json->object_class = Qnil; } tmp = ID2SYM(i_array_class); - if (st_lookup(RHASH_TBL(opts), tmp, 0)) { + if (option_given_p(opts, tmp)) { json->array_class = rb_hash_aref(opts, tmp); } else { json->array_class = Qnil; @@ -739,6 +731,7 @@ void Init_parser() i_symbolize_names = rb_intern("symbolize_names"); i_object_class = rb_intern("object_class"); i_array_class = rb_intern("array_class"); + i_key_p = rb_intern("key?"); #ifdef HAVE_RUBY_ENCODING_H mEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8")); mEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be")); |