Skip to content

Commit 98a6817

Browse files
committed
Compatibility to Rubinius
Bumped the version number to 1.2.2 and fixed some tests, too.
1 parent 77de417 commit 98a6817

File tree

8 files changed

+112
-128
lines changed

8 files changed

+112
-128
lines changed

CHANGES

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
2010-02-27 (1.2.2)
2+
* Made some changes to make the building of the parser/generator compatible
3+
to Rubinius.
14
2009-11-25 (1.2.1)
2-
* added :symbolize_names option to Parser, which returns symbols instead of
5+
* Added :symbolize_names option to Parser, which returns symbols instead of
36
strings in object names/keys.
47
2009-10-01 (1.2.0)
58
* fast_generate now raises an exeception for nan and infinite floats.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.1
1+
1.2.2

ext/json/ext/generator/generator.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
#include "unicode.h"
1010
#include <math.h>
1111

12-
#ifndef RHASH_TBL
13-
#define RHASH_TBL(hsh) (RHASH(hsh)->tbl)
14-
#endif
15-
1612
#ifndef RHASH_SIZE
1713
#define RHASH_SIZE(hsh) (RHASH(hsh)->tbl->num_entries)
1814
#endif
@@ -21,6 +17,8 @@
2117
#define RFLOAT_VALUE(val) (RFLOAT(val)->value)
2218
#endif
2319

20+
#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
21+
2422
#ifdef HAVE_RUBY_ENCODING_H
2523
#include "ruby/encoding.h"
2624
#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
@@ -43,7 +41,7 @@ static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
4341

4442
static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
4543
i_object_nl, i_array_nl, i_check_circular, i_max_nesting,
46-
i_allow_nan, i_pack, i_unpack, i_create_id, i_extend;
44+
i_allow_nan, i_pack, i_unpack, i_create_id, i_extend, i_key_p;
4745

4846
typedef struct JSON_Generator_StateStruct {
4947
VALUE indent;
@@ -543,15 +541,15 @@ static VALUE cState_configure(VALUE self, VALUE opts)
543541
state->object_nl = tmp;
544542
}
545543
tmp = ID2SYM(i_check_circular);
546-
if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
544+
if (option_given_p(opts, tmp)) {
547545
tmp = rb_hash_aref(opts, ID2SYM(i_check_circular));
548546
state->check_circular = RTEST(tmp);
549547
} else {
550548
state->check_circular = 1;
551549
}
552550
tmp = ID2SYM(i_max_nesting);
553551
state->max_nesting = 19;
554-
if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
552+
if (option_given_p(opts, tmp)) {
555553
VALUE max_nesting = rb_hash_aref(opts, tmp);
556554
if (RTEST(max_nesting)) {
557555
Check_Type(max_nesting, T_FIXNUM);
@@ -927,6 +925,7 @@ void Init_generator()
927925
i_unpack = rb_intern("unpack");
928926
i_create_id = rb_intern("create_id");
929927
i_extend = rb_intern("extend");
928+
i_key_p = rb_intern("key?");
930929
#ifdef HAVE_RUBY_ENCODING_H
931930
mEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
932931
i_encoding = rb_intern("encoding");

0 commit comments

Comments
 (0)