diff options
author | Florian Frank <flori@ping.de> | 2017-01-12 14:48:26 +0100 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2017-01-12 15:16:36 +0100 |
commit | 0a65a11b28876b0ffa1ebddc3ff8792364d962f2 (patch) | |
tree | 658670f14b9dd64ca6f84ecda0f0bf39b3a82b79 | |
parent | bc9664348b7a58f2ac0c4aef0181eccad58c66da (diff) | |
download | json-0a65a11b28876b0ffa1ebddc3ff8792364d962f2.tar.gz |
Revert "Merge decimal_class patch by Michael Jaschob"
This reverts commit 7e240ed5765867bfbdd166435f941a4cebed8cd8.
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | Rakefile | 6 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | ext/json/ext/parser/parser.c | 169 | ||||
-rw-r--r-- | ext/json/ext/parser/parser.h | 1 | ||||
-rw-r--r-- | ext/json/ext/parser/parser.rl | 23 | ||||
-rw-r--r-- | java/src/json/ext/Parser.java | 169 | ||||
-rw-r--r-- | java/src/json/ext/Parser.rl | 33 | ||||
-rw-r--r-- | json-java.gemspec (renamed from java/json.gemspec) | 6 | ||||
-rw-r--r-- | lib/json/pure/parser.rb | 6 | ||||
-rw-r--r-- | lib/json/version.rb | 2 |
11 files changed, 176 insertions, 245 deletions
diff --git a/.travis.yml b/.travis.yml index 39b6085..0688c28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,11 @@ rvm: - jruby - ruby-head matrix: + include: + - rvm: jruby + env: JRUBY_OPTS="--2.0" allow_failures: - rvm: ruby-head +before_install: "gem install bundler -v 1.12.0" script: "bundle exec rake" sudo: false @@ -251,13 +251,13 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby' desc "Package the jruby gem" task :jruby_gem => :create_jar do - sh 'gem build java/json.gemspec' + sh 'gem build json-java.gemspec' mkdir_p 'pkg' mv "json-#{PKG_VERSION}-java.gem", 'pkg' end desc "Testing library (jruby)" - task :test_ext => [ :check_env, :create_jar, :do_test_ext ] + task :test_ext => [ :create_jar, :check_env, :do_test_ext ] UndocumentedTestTask.new do |t| t.name = 'do_test_ext' @@ -331,7 +331,7 @@ else end desc "Testing library (extension)" - task :test_ext => [ :check_env, :compile, :do_test_ext ] + task :test_ext => [ :compile, :check_env, :do_test_ext ] UndocumentedTestTask.new do |t| t.name = 'do_test_ext' @@ -1 +1 @@ -2.1.0 +2.0.2 diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index 5a4da40..302ba76 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -94,16 +94,15 @@ 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_decimal_class, i_key_p, - i_deep_const_get, i_match, i_match_string, i_aset, i_aref, - i_leftshift, i_new; + i_object_class, i_array_class, i_key_p, i_deep_const_get, i_match, + i_match_string, i_aset, i_aref, i_leftshift; -#line 125 "parser.rl" +#line 124 "parser.rl" -#line 107 "parser.c" +#line 106 "parser.c" enum {JSON_object_start = 1}; enum {JSON_object_first_final = 27}; enum {JSON_object_error = 0}; @@ -111,7 +110,7 @@ enum {JSON_object_error = 0}; enum {JSON_object_en_main = 1}; -#line 166 "parser.rl" +#line 165 "parser.rl" static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting) @@ -127,14 +126,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 131 "parser.c" +#line 130 "parser.c" { cs = JSON_object_start; } -#line 181 "parser.rl" +#line 180 "parser.rl" -#line 138 "parser.c" +#line 137 "parser.c" { if ( p == pe ) goto _test_eof; @@ -162,7 +161,7 @@ case 2: goto st2; goto st0; tr2: -#line 148 "parser.rl" +#line 147 "parser.rl" { char *np; json->parsing_name = 1; @@ -175,7 +174,7 @@ st3: if ( ++p == pe ) goto _test_eof3; case 3: -#line 179 "parser.c" +#line 178 "parser.c" switch( (*p) ) { case 13: goto st3; case 32: goto st3; @@ -242,7 +241,7 @@ case 8: goto st8; goto st0; tr11: -#line 133 "parser.rl" +#line 132 "parser.rl" { VALUE v = Qnil; char *np = JSON_parse_value(json, p, pe, &v, current_nesting); @@ -262,7 +261,7 @@ st9: if ( ++p == pe ) goto _test_eof9; case 9: -#line 266 "parser.c" +#line 265 "parser.c" switch( (*p) ) { case 13: goto st9; case 32: goto st9; @@ -351,14 +350,14 @@ case 18: goto st9; goto st18; tr4: -#line 156 "parser.rl" +#line 155 "parser.rl" { p--; {p++; cs = 27; goto _out;} } goto st27; st27: if ( ++p == pe ) goto _test_eof27; case 27: -#line 362 "parser.c" +#line 361 "parser.c" goto st0; st19: if ( ++p == pe ) @@ -456,7 +455,7 @@ case 26: _out: {} } -#line 182 "parser.rl" +#line 181 "parser.rl" if (cs >= JSON_object_first_final) { if (json->create_additions) { @@ -481,7 +480,7 @@ case 26: -#line 485 "parser.c" +#line 484 "parser.c" enum {JSON_value_start = 1}; enum {JSON_value_first_final = 29}; enum {JSON_value_error = 0}; @@ -489,7 +488,7 @@ enum {JSON_value_error = 0}; enum {JSON_value_en_main = 1}; -#line 282 "parser.rl" +#line 281 "parser.rl" static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting) @@ -497,14 +496,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul int cs = EVIL; -#line 501 "parser.c" +#line 500 "parser.c" { cs = JSON_value_start; } -#line 289 "parser.rl" +#line 288 "parser.rl" -#line 508 "parser.c" +#line 507 "parser.c" { if ( p == pe ) goto _test_eof; @@ -538,14 +537,14 @@ st0: cs = 0; goto _out; tr2: -#line 234 "parser.rl" +#line 233 "parser.rl" { char *np = JSON_parse_string(json, p, pe, result); if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;} } goto st29; tr3: -#line 239 "parser.rl" +#line 238 "parser.rl" { char *np; if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) { @@ -565,7 +564,7 @@ tr3: } goto st29; tr7: -#line 257 "parser.rl" +#line 256 "parser.rl" { char *np; np = JSON_parse_array(json, p, pe, result, current_nesting + 1); @@ -573,7 +572,7 @@ tr7: } goto st29; tr11: -#line 263 "parser.rl" +#line 262 "parser.rl" { char *np; np = JSON_parse_object(json, p, pe, result, current_nesting + 1); @@ -581,7 +580,7 @@ tr11: } goto st29; tr25: -#line 227 "parser.rl" +#line 226 "parser.rl" { if (json->allow_nan) { *result = CInfinity; @@ -591,7 +590,7 @@ tr25: } goto st29; tr27: -#line 220 "parser.rl" +#line 219 "parser.rl" { if (json->allow_nan) { *result = CNaN; @@ -601,19 +600,19 @@ tr27: } goto st29; tr31: -#line 214 "parser.rl" +#line 213 "parser.rl" { *result = Qfalse; } goto st29; tr34: -#line 211 "parser.rl" +#line 210 "parser.rl" { *result = Qnil; } goto st29; tr37: -#line 217 "parser.rl" +#line 216 "parser.rl" { *result = Qtrue; } @@ -622,9 +621,9 @@ st29: if ( ++p == pe ) goto _test_eof29; case 29: -#line 269 "parser.rl" +#line 268 "parser.rl" { p--; {p++; cs = 29; goto _out;} } -#line 628 "parser.c" +#line 627 "parser.c" switch( (*p) ) { case 13: goto st29; case 32: goto st29; @@ -865,7 +864,7 @@ case 28: _out: {} } -#line 290 "parser.rl" +#line 289 "parser.rl" if (cs >= JSON_value_first_final) { return p; @@ -875,7 +874,7 @@ case 28: } -#line 879 "parser.c" +#line 878 "parser.c" enum {JSON_integer_start = 1}; enum {JSON_integer_first_final = 3}; enum {JSON_integer_error = 0}; @@ -883,7 +882,7 @@ enum {JSON_integer_error = 0}; enum {JSON_integer_en_main = 1}; -#line 306 "parser.rl" +#line 305 "parser.rl" static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -891,15 +890,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res int cs = EVIL; -#line 895 "parser.c" +#line 894 "parser.c" { cs = JSON_integer_start; } -#line 313 "parser.rl" +#line 312 "parser.rl" json->memo = p; -#line 903 "parser.c" +#line 902 "parser.c" { if ( p == pe ) goto _test_eof; @@ -933,14 +932,14 @@ case 3: goto st0; goto tr4; tr4: -#line 303 "parser.rl" +#line 302 "parser.rl" { p--; {p++; cs = 4; goto _out;} } goto st4; st4: if ( ++p == pe ) goto _test_eof4; case 4: -#line 944 "parser.c" +#line 943 "parser.c" goto st0; st5: if ( ++p == pe ) @@ -959,7 +958,7 @@ case 5: _out: {} } -#line 315 "parser.rl" +#line 314 "parser.rl" if (cs >= JSON_integer_first_final) { long len = p - json->memo; @@ -974,7 +973,7 @@ case 5: } -#line 978 "parser.c" +#line 977 "parser.c" enum {JSON_float_start = 1}; enum {JSON_float_first_final = 8}; enum {JSON_float_error = 0}; @@ -982,7 +981,7 @@ enum {JSON_float_error = 0}; enum {JSON_float_en_main = 1}; -#line 340 "parser.rl" +#line 339 "parser.rl" static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result) @@ -990,15 +989,15 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul int cs = EVIL; -#line 994 "parser.c" +#line 993 "parser.c" { cs = JSON_float_start; } -#line 347 "parser.rl" +#line 346 "parser.rl" json->memo = p; -#line 1002 "parser.c" +#line 1001 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1056,14 +1055,14 @@ case 8: goto st0; goto tr9; tr9: -#line 334 "parser.rl" +#line 333 "parser.rl" { p--; {p++; cs = 9; goto _out;} } goto st9; st9: if ( ++p == pe ) goto _test_eof9; case 9: -#line 1067 "parser.c" +#line 1066 "parser.c" goto st0; st5: if ( ++p == pe ) @@ -1124,21 +1123,14 @@ case 7: _out: {} } -#line 349 "parser.rl" +#line 348 "parser.rl" if (cs >= JSON_float_first_final) { long len = p - json->memo; fbuffer_clear(json->fbuffer); fbuffer_append(json->fbuffer, json->memo, len); fbuffer_append_char(json->fbuffer, '\0'); - if (NIL_P(json->decimal_class)) { - *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1)); - } - else { - VALUE text; - text = rb_str_new2(FBUFFER_PTR(json->fbuffer)); - *result = rb_funcall(json->decimal_class, i_new, 1, text); - } + *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1)); return p + 1; } else { return NULL; @@ -1147,7 +1139,7 @@ case 7: -#line 1151 "parser.c" +#line 1143 "parser.c" enum {JSON_array_start = 1}; enum {JSON_array_first_final = 17}; enum {JSON_array_error = 0}; @@ -1155,7 +1147,7 @@ enum {JSON_array_error = 0}; enum {JSON_array_en_main = 1}; -#line 399 "parser.rl" +#line 391 "parser.rl" static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting) @@ -1169,14 +1161,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 1173 "parser.c" +#line 1165 "parser.c" { cs = JSON_array_start; } -#line 412 "parser.rl" +#line 404 "parser.rl" -#line 1180 "parser.c" +#line 1172 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1215,7 +1207,7 @@ case 2: goto st2; goto st0; tr2: -#line 376 "parser.rl" +#line 368 "parser.rl" { VALUE v = Qnil; char *np = JSON_parse_value(json, p, pe, &v, current_nesting); @@ -1235,7 +1227,7 @@ st3: if ( ++p == pe ) goto _test_eof3; case 3: -#line 1239 "parser.c" +#line 1231 "parser.c" switch( (*p) ) { case 13: goto st3; case 32: goto st3; @@ -1335,14 +1327,14 @@ case 12: goto st3; goto st12; tr4: -#line 391 "parser.rl" +#line 383 "parser.rl" { p--; {p++; cs = 17; goto _out;} } goto st17; st17: if ( ++p == pe ) goto _test_eof17; case 17: -#line 1346 "parser.c" +#line 1338 "parser.c" goto st0; st13: if ( ++p == pe ) @@ -1398,7 +1390,7 @@ case 16: _out: {} } -#line 413 "parser.rl" +#line 405 "parser.rl" if(cs >= JSON_array_first_final) { return p + 1; @@ -1479,7 +1471,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) } -#line 1483 "parser.c" +#line 1475 "parser.c" enum {JSON_string_start = 1}; enum {JSON_string_first_final = 8}; enum {JSON_string_error = 0}; @@ -1487,7 +1479,7 @@ enum {JSON_string_error = 0}; enum {JSON_string_en_main = 1}; -#line 512 "parser.rl" +#line 504 "parser.rl" static int @@ -1509,15 +1501,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu *result = rb_str_buf_new(0); -#line 1513 "parser.c" +#line 1505 "parser.c" { cs = JSON_string_start; } -#line 533 "parser.rl" +#line 525 "parser.rl" json->memo = p; -#line 1521 "parser.c" +#line 1513 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1542,7 +1534,7 @@ case 2: goto st0; goto st2; tr2: -#line 498 "parser.rl" +#line 490 "parser.rl" { *result = json_string_unescape(*result, json->memo + 1, p); if (NIL_P(*result)) { @@ -1553,14 +1545,14 @@ tr2: {p = (( p + 1))-1;} } } -#line 509 "parser.rl" +#line 501 "parser.rl" { p--; {p++; cs = 8; goto _out;} } goto st8; st8: if ( ++p == pe ) goto _test_eof8; case 8: -#line 1564 "parser.c" +#line 1556 "parser.c" goto st0; st3: if ( ++p == pe ) @@ -1636,7 +1628,7 @@ case 7: _out: {} } -#line 535 "parser.rl" +#line 527 "parser.rl" if (json->create_additions && RTEST(match_string = json->match_string)) { VALUE klass; @@ -1789,12 +1781,6 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } else { json->array_class = Qnil; } - tmp = ID2SYM(i_decimal_class); - if (option_given_p(opts, tmp)) { - json->decimal_class = rb_hash_aref(opts, tmp); - } else { - json->decimal_class = Qnil; - } tmp = ID2SYM(i_match_string); if (option_given_p(opts, tmp)) { VALUE match_string = rb_hash_aref(opts, tmp); @@ -1812,7 +1798,6 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) json->create_id = rb_funcall(mJSON, i_create_id, 0); json->object_class = Qnil; json->array_class = Qnil; - json->decimal_class = Qnil; } source = convert_encoding(StringValue(source)); StringValue(source); @@ -1823,7 +1808,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } -#line 1827 "parser.c" +#line 1812 "parser.c" enum {JSON_start = 1}; enum {JSON_first_final = 10}; enum {JSON_error = 0}; @@ -1831,7 +1816,7 @@ enum {JSON_error = 0}; enum {JSON_en_main = 1}; -#line 735 "parser.rl" +#line 720 "parser.rl" /* @@ -1848,16 +1833,16 @@ static VALUE cParser_parse(VALUE self) GET_PARSER; -#line 1852 "parser.c" +#line 1837 "parser.c" { cs = JSON_start; } -#line 751 "parser.rl" +#line 736 "parser.rl" p = json->source; pe = p + json->len; -#line 1861 "parser.c" +#line 1846 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1891,7 +1876,7 @@ st0: cs = 0; goto _out; tr2: -#line 727 "parser.rl" +#line 712 "parser.rl" { char *np = JSON_parse_value(json, p, pe, &result, 0); if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} @@ -1901,7 +1886,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 1905 "parser.c" +#line 1890 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -1990,7 +1975,7 @@ case 9: _out: {} } -#line 754 "parser.rl" +#line 739 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; @@ -2007,7 +1992,6 @@ static void JSON_mark(void *ptr) rb_gc_mark_maybe(json->create_id); rb_gc_mark_maybe(json->object_class); rb_gc_mark_maybe(json->array_class); - rb_gc_mark_maybe(json->decimal_class); rb_gc_mark_maybe(json->match_string); } @@ -2082,7 +2066,6 @@ void Init_parser(void) i_symbolize_names = rb_intern("symbolize_names"); i_object_class = rb_intern("object_class"); i_array_class = rb_intern("array_class"); - i_decimal_class = rb_intern("decimal_class"); i_match = rb_intern("match"); i_match_string = rb_intern("match_string"); i_key_p = rb_intern("key?"); diff --git a/ext/json/ext/parser/parser.h b/ext/json/ext/parser/parser.h index e6cf779..1d46831 100644 --- a/ext/json/ext/parser/parser.h +++ b/ext/json/ext/parser/parser.h @@ -39,7 +39,6 @@ typedef struct JSON_ParserStruct { int symbolize_names; VALUE object_class; VALUE array_class; - VALUE decimal_class; int create_additions; VALUE match_string; FBuffer *fbuffer; diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl index dc66026..5964907 100644 --- a/ext/json/ext/parser/parser.rl +++ b/ext/json/ext/parser/parser.rl @@ -92,9 +92,8 @@ 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_decimal_class, i_key_p, - i_deep_const_get, i_match, i_match_string, i_aset, i_aref, - i_leftshift, i_new; + i_object_class, i_array_class, i_key_p, i_deep_const_get, i_match, + i_match_string, i_aset, i_aref, i_leftshift; %%{ machine JSON_common; @@ -352,14 +351,7 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul fbuffer_clear(json->fbuffer); fbuffer_append(json->fbuffer, json->memo, len); fbuffer_append_char(json->fbuffer, '\0'); - if (NIL_P(json->decimal_class)) { - *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1)); - } - else { - VALUE text; - text = rb_str_new2(FBUFFER_PTR(json->fbuffer)); - *result = rb_funcall(json->decimal_class, i_new, 1, text); - } + *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1)); return p + 1; } else { return NULL; @@ -684,12 +676,6 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } else { json->array_class = Qnil; } - tmp = ID2SYM(i_decimal_class); - if (option_given_p(opts, tmp)) { - json->decimal_class = rb_hash_aref(opts, tmp); - } else { - json->decimal_class = Qnil; - } tmp = ID2SYM(i_match_string); if (option_given_p(opts, tmp)) { VALUE match_string = rb_hash_aref(opts, tmp); @@ -707,7 +693,6 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) json->create_id = rb_funcall(mJSON, i_create_id, 0); json->object_class = Qnil; json->array_class = Qnil; - json->decimal_class = Qnil; } source = convert_encoding(StringValue(source)); StringValue(source); @@ -767,7 +752,6 @@ static void JSON_mark(void *ptr) rb_gc_mark_maybe(json->create_id); rb_gc_mark_maybe(json->object_class); rb_gc_mark_maybe(json->array_class); - rb_gc_mark_maybe(json->decimal_class); rb_gc_mark_maybe(json->match_string); } @@ -842,7 +826,6 @@ void Init_parser(void) i_symbolize_names = rb_intern("symbolize_names"); i_object_class = rb_intern("object_class"); i_array_class = rb_intern("array_class"); - i_decimal_class = rb_intern("decimal_class"); i_match = rb_intern("match"); i_match_string = rb_intern("match_string"); i_key_p = rb_intern("key?"); diff --git a/java/src/json/ext/Parser.java b/java/src/json/ext/Parser.java index 2ba9f8f..2a7d9f5 100644 --- a/java/src/json/ext/Parser.java +++ b/java/src/json/ext/Parser.java @@ -54,7 +54,6 @@ public class Parser extends RubyObject { private boolean symbolizeNames; private RubyClass objectClass; private RubyClass arrayClass; - private RubyClass decimalClass; private RubyHash matchString; private static final int DEFAULT_MAX_NESTING = 100; @@ -134,10 +133,6 @@ public class Parser extends RubyObject { * <dt><code>:array_class</code> * <dd>Defaults to Array. * - * <dt><code>:decimal_class</code> - * <dd>Specifies which class to use instead of the default (Float) when - * parsing decimal numbers. This class must accept a single string argument - * in its constructor. * </dl> */ @JRubyMethod(name = "new", required = 1, optional = 1, meta = true) @@ -164,7 +159,6 @@ public class Parser extends RubyObject { this.createAdditions = opts.getBool("create_additions", false); this.objectClass = opts.getClass("object_class", runtime.getHash()); this.arrayClass = opts.getClass("array_class", runtime.getArray()); - this.decimalClass = opts.getClass("decimal_class", null); this.matchString = opts.getHash("match_string"); if(symbolizeNames && createAdditions) { @@ -313,11 +307,11 @@ public class Parser extends RubyObject { } -// line 339 "Parser.rl" +// line 333 "Parser.rl" -// line 321 "Parser.java" +// line 315 "Parser.java" private static byte[] init__JSON_value_actions_0() { return new byte [] { @@ -431,7 +425,7 @@ static final int JSON_value_error = 0; static final int JSON_value_en_main = 1; -// line 445 "Parser.rl" +// line 439 "Parser.rl" void parseValue(ParserResult res, int p, int pe) { @@ -439,14 +433,14 @@ static final int JSON_value_en_main = 1; IRubyObject result = null; -// line 443 "Parser.java" +// line 437 "Parser.java" { cs = JSON_value_start; } -// line 452 "Parser.rl" +// line 446 "Parser.rl" -// line 450 "Parser.java" +// line 444 "Parser.java" { int _klen; int _trans = 0; @@ -472,13 +466,13 @@ case 1: while ( _nacts-- > 0 ) { switch ( _JSON_value_actions[_acts++] ) { case 9: -// line 430 "Parser.rl" +// line 424 "Parser.rl" { p--; { p += 1; _goto_targ = 5; if (true) continue _goto;} } break; -// line 482 "Parser.java" +// line 476 "Parser.java" } } @@ -541,25 +535,25 @@ case 1: switch ( _JSON_value_actions[_acts++] ) { case 0: -// line 347 "Parser.rl" +// line 341 "Parser.rl" { result = getRuntime().getNil(); } break; case 1: -// line 350 "Parser.rl" +// line 344 "Parser.rl" { result = getRuntime().getFalse(); } break; case 2: -// line 353 "Parser.rl" +// line 347 "Parser.rl" { result = getRuntime().getTrue(); } break; case 3: -// line 356 "Parser.rl" +// line 350 "Parser.rl" { if (parser.allowNaN) { result = getConstant(CONST_NAN); @@ -569,7 +563,7 @@ case 1: } break; case 4: -// line 363 "Parser.rl" +// line 357 "Parser.rl" { if (parser.allowNaN) { result = getConstant(CONST_INFINITY); @@ -579,7 +573,7 @@ case 1: } break; case 5: -// line 370 "Parser.rl" +// line 364 "Parser.rl" { if (pe > p + 8 && absSubSequence(p, p + 9).equals(JSON_MINUS_INFINITY)) { @@ -608,7 +602,7 @@ case 1: } break; case 6: -// line 396 "Parser.rl" +// line 390 "Parser.rl" { parseString(res, p, pe); if (res.result == null) { @@ -621,7 +615,7 @@ case 1: } break; case 7: -// line 406 "Parser.rl" +// line 400 "Parser.rl" { currentNesting++; parseArray(res, p, pe); @@ -636,7 +630,7 @@ case 1: } break; case 8: -// line 418 "Parser.rl" +// line 412 "Parser.rl" { currentNesting++; parseObject(res, p, pe); @@ -650,7 +644,7 @@ case 1: } } break; -// line 654 "Parser.java" +// line 648 "Parser.java" } } } @@ -670,7 +664,7 @@ case 5: break; } } -// line 453 "Parser.rl" +// line 447 "Parser.rl" if (cs >= JSON_value_first_final && result != null) { res.update(result, p); @@ -680,7 +674,7 @@ case 5: } -// line 684 "Parser.java" +// line 678 "Parser.java" private static byte[] init__JSON_integer_actions_0() { return new byte [] { @@ -779,7 +773,7 @@ static final int JSON_integer_error = 0; static final int JSON_integer_en_main = 1; -// line 472 "Parser.rl" +// line 466 "Parser.rl" void parseInteger(ParserResult res, int p, int pe) { @@ -797,15 +791,15 @@ static final int JSON_integer_en_main = 1; int cs = EVIL; -// line 801 "Parser.java" +// line 795 "Parser.java" { cs = JSON_integer_start; } -// line 489 "Parser.rl" +// line 483 "Parser.rl" int memo = p; -// line 809 "Parser.java" +// line 803 "Parser.java" { int _klen; int _trans = 0; @@ -886,13 +880,13 @@ case 1: switch ( _JSON_integer_actions[_acts++] ) { case 0: -// line 466 "Parser.rl" +// line 460 "Parser.rl" { p--; { p += 1; _goto_targ = 5; if (true) continue _goto;} } break; -// line 896 "Parser.java" +// line 890 "Parser.java" } } } @@ -912,7 +906,7 @@ case 5: break; } } -// line 491 "Parser.rl" +// line 485 "Parser.rl" if (cs < JSON_integer_first_final) { return -1; @@ -920,13 +914,13 @@ case 5: return p; } - + RubyInteger createInteger(int p, int new_p) { Ruby runtime = getRuntime(); ByteList num = absSubSequence(p, new_p); return bytesToInum(runtime, num); } - + RubyInteger bytesToInum(Ruby runtime, ByteList num) { return runtime.is1_9() ? ConvertBytes.byteListToInum19(runtime, num, 10, true) : @@ -934,7 +928,7 @@ case 5: } -// line 938 "Parser.java" +// line 932 "Parser.java" private static byte[] init__JSON_float_actions_0() { return new byte [] { @@ -1036,7 +1030,7 @@ static final int JSON_float_error = 0; static final int JSON_float_en_main = 1; -// line 526 "Parser.rl" +// line 520 "Parser.rl" void parseFloat(ParserResult res, int p, int pe) { @@ -1045,9 +1039,7 @@ static final int JSON_float_en_main = 1; res.update(null, p); return; } - IRubyObject number = parser.decimalClass == null ? - createFloat(p, new_p) : createCustomDecimal(p, new_p); - + RubyFloat number = createFloat(p, new_p); res.update(number, new_p + 1); return; } @@ -1056,15 +1048,15 @@ static final int JSON_float_en_main = 1; int cs = EVIL; -// line 1060 "Parser.java" +// line 1052 "Parser.java" { cs = JSON_float_start; } -// line 545 "Parser.rl" +// line 537 "Parser.rl" int memo = p; -// line 1068 "Parser.java" +// line 1060 "Parser.java" { int _klen; int _trans = 0; @@ -1145,13 +1137,13 @@ case 1: switch ( _JSON_float_actions[_acts++] ) { case 0: -// line 517 "Parser.rl" +// line 511 "Parser.rl" { p--; { p += 1; _goto_targ = 5; if (true) continue _goto;} } break; -// line 1155 "Parser.java" +// line 1147 "Parser.java" } } } @@ -1171,30 +1163,23 @@ case 5: break; } } -// line 547 "Parser.rl" +// line 539 "Parser.rl" if (cs < JSON_float_first_final) { return -1; } - + return p; } - + RubyFloat createFloat(int p, int new_p) { Ruby runtime = getRuntime(); ByteList num = absSubSequence(p, new_p); return RubyFloat.newFloat(runtime, dc.parse(num, true, runtime.is1_9())); } - IRubyObject createCustomDecimal(int p, int new_p) { - Ruby runtime = getRuntime(); - ByteList num = absSubSequence(p, new_p); - IRubyObject numString = runtime.newString(num.toString()); - return parser.decimalClass.callMethod(context, "new", numString); - } - -// line 1198 "Parser.java" +// line 1183 "Parser.java" private static byte[] init__JSON_string_actions_0() { return new byte [] { @@ -1296,7 +1281,7 @@ static final int JSON_string_error = 0; static final int JSON_string_en_main = 1; -// line 599 "Parser.rl" +// line 584 "Parser.rl" void parseString(ParserResult res, int p, int pe) { @@ -1304,15 +1289,15 @@ static final int JSON_string_en_main = 1; IRubyObject result = null; -// line 1308 "Parser.java" +// line 1293 "Parser.java" { cs = JSON_string_start; } -// line 606 "Parser.rl" +// line 591 "Parser.rl" int memo = p; -// line 1316 "Parser.java" +// line 1301 "Parser.java" { int _klen; int _trans = 0; @@ -1393,7 +1378,7 @@ case 1: switch ( _JSON_string_actions[_acts++] ) { case 0: -// line 574 "Parser.rl" +// line 559 "Parser.rl" { int offset = byteList.begin(); ByteList decoded = decoder.decode(byteList, memo + 1 - offset, @@ -1408,13 +1393,13 @@ case 1: } break; case 1: -// line 587 "Parser.rl" +// line 572 "Parser.rl" { p--; { p += 1; _goto_targ = 5; if (true) continue _goto;} } break; -// line 1418 "Parser.java" +// line 1403 "Parser.java" } } } @@ -1434,7 +1419,7 @@ case 5: break; } } -// line 608 "Parser.rl" +// line 593 "Parser.rl" if (parser.createAdditions) { RubyHash matchString = parser.matchString; @@ -1461,7 +1446,7 @@ case 5: } } - if (cs >= JSON_string_first_final && result != null) { + if (cs >= JSON_string_first_final && result != null) { if (result instanceof RubyString) { ((RubyString)result).force_encoding(context, info.utf8.get()); } @@ -1472,7 +1457,7 @@ case 5: } -// line 1476 "Parser.java" +// line 1461 "Parser.java" private static byte[] init__JSON_array_actions_0() { return new byte [] { @@ -1585,7 +1570,7 @@ static final int JSON_array_error = 0; static final int JSON_array_en_main = 1; -// line 681 "Parser.rl" +// line 666 "Parser.rl" void parseArray(ParserResult res, int p, int pe) { @@ -1605,14 +1590,14 @@ static final int JSON_array_en_main = 1; } -// line 1609 "Parser.java" +// line 1594 "Parser.java" { cs = JSON_array_start; } -// line 700 "Parser.rl" +// line 685 "Parser.rl" -// line 1616 "Parser.java" +// line 1601 "Parser.java" { int _klen; int _trans = 0; @@ -1693,7 +1678,7 @@ case 1: switch ( _JSON_array_actions[_acts++] ) { case 0: -// line 650 "Parser.rl" +// line 635 "Parser.rl" { parseValue(res, p, pe); if (res.result == null) { @@ -1710,13 +1695,13 @@ case 1: } break; case 1: -// line 665 "Parser.rl" +// line 650 "Parser.rl" { p--; { p += 1; _goto_targ = 5; if (true) continue _goto;} } break; -// line 1720 "Parser.java" +// line 1705 "Parser.java" } } } @@ -1736,7 +1721,7 @@ case 5: break; } } -// line 701 "Parser.rl" +// line 686 "Parser.rl" if (cs >= JSON_array_first_final) { res.update(result, p + 1); @@ -1746,7 +1731,7 @@ case 5: } -// line 1750 "Parser.java" +// line 1735 "Parser.java" private static byte[] init__JSON_object_actions_0() { return new byte [] { @@ -1869,7 +1854,7 @@ static final int JSON_object_error = 0; static final int JSON_object_en_main = 1; -// line 760 "Parser.rl" +// line 745 "Parser.rl" void parseObject(ParserResult res, int p, int pe) { @@ -1894,14 +1879,14 @@ static final int JSON_object_en_main = 1; } -// line 1898 "Parser.java" +// line 1883 "Parser.java" { cs = JSON_object_start; } -// line 784 "Parser.rl" +// line 769 "Parser.rl" -// line 1905 "Parser.java" +// line 1890 "Parser.java" { int _klen; int _trans = 0; @@ -1982,7 +1967,7 @@ case 1: switch ( _JSON_object_actions[_acts++] ) { case 0: -// line 715 "Parser.rl" +// line 700 "Parser.rl" { parseValue(res, p, pe); if (res.result == null) { @@ -1999,7 +1984,7 @@ case 1: } break; case 1: -// line 730 "Parser.rl" +// line 715 "Parser.rl" { parseString(res, p, pe); if (res.result == null) { @@ -2019,13 +2004,13 @@ case 1: } break; case 2: -// line 748 "Parser.rl" +// line 733 "Parser.rl" { p--; { p += 1; _goto_targ = 5; if (true) continue _goto;} } break; -// line 2029 "Parser.java" +// line 2014 "Parser.java" } } } @@ -2045,7 +2030,7 @@ case 5: break; } } -// line 785 "Parser.rl" +// line 770 "Parser.rl" if (cs < JSON_object_first_final) { res.update(null, p + 1); @@ -2078,7 +2063,7 @@ case 5: } -// line 2082 "Parser.java" +// line 2067 "Parser.java" private static byte[] init__JSON_actions_0() { return new byte [] { @@ -2181,7 +2166,7 @@ static final int JSON_error = 0; static final int JSON_en_main = 1; -// line 836 "Parser.rl" +// line 821 "Parser.rl" public IRubyObject parseImplemetation() { @@ -2191,16 +2176,16 @@ static final int JSON_en_main = 1; ParserResult res = new ParserResult(); -// line 2195 "Parser.java" +// line 2180 "Parser.java" { cs = JSON_start; } -// line 845 "Parser.rl" +// line 830 "Parser.rl" p = byteList.begin(); pe = p + byteList.length(); -// line 2204 "Parser.java" +// line 2189 "Parser.java" { int _klen; int _trans = 0; @@ -2281,7 +2266,7 @@ case 1: switch ( _JSON_actions[_acts++] ) { case 0: -// line 822 "Parser.rl" +// line 807 "Parser.rl" { parseValue(res, p, pe); if (res.result == null) { @@ -2293,7 +2278,7 @@ case 1: } } break; -// line 2297 "Parser.java" +// line 2282 "Parser.java" } } } @@ -2313,7 +2298,7 @@ case 5: break; } } -// line 848 "Parser.rl" +// line 833 "Parser.rl" if (cs >= JSON_first_final && p == pe) { return result; diff --git a/java/src/json/ext/Parser.rl b/java/src/json/ext/Parser.rl index 4d170e1..1ad8f21 100644 --- a/java/src/json/ext/Parser.rl +++ b/java/src/json/ext/Parser.rl @@ -52,8 +52,7 @@ public class Parser extends RubyObject { private boolean symbolizeNames; private RubyClass objectClass; private RubyClass arrayClass; - private RubyClass decimalClass; - private RubyHash match_string; + private RubyHash matchString; private static final int DEFAULT_MAX_NESTING = 100; @@ -132,10 +131,6 @@ public class Parser extends RubyObject { * <dt><code>:array_class</code> * <dd>Defaults to Array. * - * <dt><code>:decimal_class</code> - * <dd>Specifies which class to use instead of the default (Float) when - * parsing decimal numbers. This class must accept a single string argument - * in its constructor. * </dl> */ @JRubyMethod(name = "new", required = 1, optional = 1, meta = true) @@ -162,8 +157,7 @@ public class Parser extends RubyObject { this.createAdditions = opts.getBool("create_additions", false); this.objectClass = opts.getClass("object_class", runtime.getHash()); this.arrayClass = opts.getClass("array_class", runtime.getArray()); - this.decimalClass = opts.getClass("decimal_class", null); - this.match_string = opts.getHash("match_string"); + this.matchString = opts.getHash("match_string"); if(symbolizeNames && createAdditions) { throw runtime.newArgumentError( @@ -495,13 +489,13 @@ public class Parser extends RubyObject { return p; } - + RubyInteger createInteger(int p, int new_p) { Ruby runtime = getRuntime(); ByteList num = absSubSequence(p, new_p); return bytesToInum(runtime, num); } - + RubyInteger bytesToInum(Ruby runtime, ByteList num) { return runtime.is1_9() ? ConvertBytes.byteListToInum19(runtime, num, 10, true) : @@ -531,9 +525,7 @@ public class Parser extends RubyObject { res.update(null, p); return; } - IRubyObject number = parser.decimalClass == null ? - createFloat(p, new_p) : createCustomDecimal(p, new_p); - + RubyFloat number = createFloat(p, new_p); res.update(number, new_p + 1); return; } @@ -548,23 +540,16 @@ public class Parser extends RubyObject { if (cs < JSON_float_first_final) { return -1; } - + return p; } - + RubyFloat createFloat(int p, int new_p) { Ruby runtime = getRuntime(); ByteList num = absSubSequence(p, new_p); return RubyFloat.newFloat(runtime, dc.parse(num, true, runtime.is1_9())); } - IRubyObject createCustomDecimal(int p, int new_p) { - Ruby runtime = getRuntime(); - ByteList num = absSubSequence(p, new_p); - IRubyObject numString = runtime.newString(num.toString()); - return parser.decimalClass.callMethod(context, "new", numString); - } - %%{ machine JSON_string; include JSON_common; @@ -631,7 +616,7 @@ public class Parser extends RubyObject { } } - if (cs >= JSON_string_first_final && result != null) { + if (cs >= JSON_string_first_final && result != null) { if (result instanceof RubyString) { ((RubyString)result).force_encoding(context, info.utf8.get()); } @@ -749,7 +734,7 @@ public class Parser extends RubyObject { fhold; fbreak; } - + pair = ignore* begin_name >parse_name ignore* name_separator ignore* begin_value >parse_value; next_pair = ignore* value_separator pair; diff --git a/java/json.gemspec b/json-java.gemspec index e0e4efe..1524b1f 100644 --- a/java/json.gemspec +++ b/json-java.gemspec @@ -3,11 +3,7 @@ require "rubygems" spec = Gem::Specification.new do |s| s.name = "json" - s.version = if File.exist?('VERSION') - File.read("VERSION").chomp - else - File.read("../VERSION").chomp - end + s.version = File.read("VERSION").chomp s.summary = "JSON implementation for JRuby" s.description = "A JSON implementation as a JRuby extension." s.author = "Daniel Luz" diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb index 3a6343b..b907236 100644 --- a/lib/json/pure/parser.rb +++ b/lib/json/pure/parser.rb @@ -70,9 +70,6 @@ module JSON # option defaults to false. # * *object_class*: Defaults to Hash # * *array_class*: Defaults to Array - # * *decimal_class*: Specifies which class to use instead of the default - # (Float) when parsing decimal numbers. This class must accept a single - # string argument in its constructor. def initialize(source, opts = {}) opts ||= {} source = convert_encoding source @@ -97,7 +94,6 @@ module JSON @create_id = @create_additions ? JSON.create_id : nil @object_class = opts[:object_class] || Hash @array_class = opts[:array_class] || Array - @decimal_class = opts[:decimal_class] @match_string = opts[:match_string] end @@ -197,7 +193,7 @@ module JSON def parse_value case when scan(FLOAT) - @decimal_class && @decimal_class.new(self[1]) || Float(self[1]) + Float(self[1]) when scan(INTEGER) Integer(self[1]) when scan(TRUE) diff --git a/lib/json/version.rb b/lib/json/version.rb index b65ed87..8997def 100644 --- a/lib/json/version.rb +++ b/lib/json/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false module JSON # JSON version - VERSION = '2.1.0' + VERSION = '2.0.2' VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc: VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: |