Skip to content

Commit

Permalink
Compatibility to Rubinius
Browse files Browse the repository at this point in the history
Bumped the version number to 1.2.2 and fixed some tests, too.
  • Loading branch information
flori committed Feb 27, 2010
1 parent 77de417 commit 98a6817
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 128 deletions.
5 changes: 4 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2010-02-27 (1.2.2)
* Made some changes to make the building of the parser/generator compatible
to Rubinius.
2009-11-25 (1.2.1)
* added :symbolize_names option to Parser, which returns symbols instead of
* Added :symbolize_names option to Parser, which returns symbols instead of
strings in object names/keys.
2009-10-01 (1.2.0)
* fast_generate now raises an exeception for nan and infinite floats.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.1
1.2.2
13 changes: 6 additions & 7 deletions ext/json/ext/generator/generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand All @@ -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;
Expand Down Expand Up @@ -543,15 +541,15 @@ 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 {
state->check_circular = 1;
}
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);
Expand Down Expand Up @@ -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");
Expand Down
Loading

0 comments on commit 98a6817

Please sign in to comment.