Skip to content

Commit

Permalink
* ext/json, lib/json, test/json: Update to JSON 1.1.2.
Browse files Browse the repository at this point in the history
  (RubyForge#15447)

* math.c: fix typo.
-- 

M    ChangeLog
M    math.c
M    ext/json/ext/generator/generator.c
M    ext/json/ext/parser/parser.rl
M    ext/json/ext/parser/parser.c
M    lib/json/version.rb
M    lib/json/editor.rb
M    lib/json/common.rb
M    lib/json/pure/parser.rb
M    test/json/test_json_unicode.rb
M    test/json/test_json_fixtures.rb
M    test/json/test_json_generate.rb
M    test/json/test_json_addition.rb
M    test/json/test_json.rb
M    test/json/runner.rb


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nurse committed Nov 28, 2007
1 parent 6272cf8 commit 0cf0b82
Show file tree
Hide file tree
Showing 15 changed files with 346 additions and 152 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Wed Nov 28 18:08:00 2007 NARUSE, Yui <[email protected]>

* ext/json, lib/json, test/json: Update to JSON 1.1.2.
(RubyForge#15447)

* math.c: fix typo.

Wed Nov 28 16:29:35 2007 Koichi Sasada <[email protected]>

* insnhelper.ci (vm_invoke_block): should splat args.
Expand Down
23 changes: 18 additions & 5 deletions ext/json/ext/generator/generator.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* vim: set cin et sw=4 ts=4: */

#include "ruby/ruby.h"
#include <string.h>
#include "ruby.h"
#include "ruby/st.h"
#include "unicode.h"
#include <string.h>
#include <math.h>

#define check_max_nesting(state, depth) do { \
Expand Down Expand Up @@ -69,6 +69,7 @@ static int hash_to_json_state_i(VALUE key, VALUE value, VALUE Vstate)
rb_str_buf_append(buf, rb_str_times(state->indent, Vdepth));
}
json = rb_funcall(rb_funcall(key, i_to_s, 0), i_to_json, 2, Vstate, Vdepth);
Check_Type(json, T_STRING);
rb_str_buf_append(buf, json);
OBJ_INFECT(buf, json);
if (RSTRING_LEN(state->space_before)) {
Expand All @@ -77,6 +78,7 @@ static int hash_to_json_state_i(VALUE key, VALUE value, VALUE Vstate)
rb_str_buf_cat2(buf, ":");
if (RSTRING_LEN(state->space)) rb_str_buf_append(buf, state->space);
json = rb_funcall(value, i_to_json, 2, Vstate, Vdepth);
Check_Type(json, T_STRING);
state->flag = 1;
rb_str_buf_append(buf, json);
OBJ_INFECT(buf, json);
Expand Down Expand Up @@ -113,10 +115,12 @@ static int hash_to_json_i(VALUE key, VALUE value, VALUE buf)
if (key == Qundef) return ST_CONTINUE;
if (RSTRING_LEN(buf) > 1) rb_str_buf_cat2(buf, ",");
tmp = rb_funcall(rb_funcall(key, i_to_s, 0), i_to_json, 0);
Check_Type(tmp, T_STRING);
rb_str_buf_append(buf, tmp);
OBJ_INFECT(buf, tmp);
rb_str_buf_cat2(buf, ":");
tmp = rb_funcall(value, i_to_json, 0);
Check_Type(tmp, T_STRING);
rb_str_buf_append(buf, tmp);
OBJ_INFECT(buf, tmp);

Expand Down Expand Up @@ -192,7 +196,9 @@ inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth
OBJ_INFECT(result, element);
if (i > 0) rb_str_buf_append(result, delim);
rb_str_buf_append(result, shift);
rb_str_buf_append(result, rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1)));
element = rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1));
Check_Type(element, T_STRING);
rb_str_buf_append(result, element);
}
if (RSTRING_LEN(state->array_nl)) {
rb_str_buf_append(result, state->array_nl);
Expand All @@ -213,7 +219,9 @@ inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth
OBJ_INFECT(result, element);
if (i > 0) rb_str_buf_append(result, delim);
rb_str_buf_append(result, shift);
rb_str_buf_append(result, rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1)));
element = rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1));
Check_Type(element, T_STRING);
rb_str_buf_append(result, element);
}
rb_str_buf_append(result, state->array_nl);
if (RSTRING_LEN(state->array_nl)) {
Expand Down Expand Up @@ -246,7 +254,9 @@ static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {
VALUE element = RARRAY_PTR(self)[i];
OBJ_INFECT(result, element);
if (i > 0) rb_str_buf_cat2(result, ",");
rb_str_buf_append(result, rb_funcall(element, i_to_json, 0));
element = rb_funcall(element, i_to_json, 0);
Check_Type(element, T_STRING);
rb_str_buf_append(result, element);
}
rb_str_buf_cat2(result, "]");
} else {
Expand Down Expand Up @@ -787,6 +797,9 @@ static VALUE cState_forget(VALUE self, VALUE object)
return rb_hash_delete(state->seen, rb_obj_id(object));
}

/*
*
*/
void Init_generator()
{
mJSON = rb_define_module("JSON");
Expand Down
Loading

0 comments on commit 0cf0b82

Please sign in to comment.