json 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +5 -2
- data/CHANGES.md +33 -0
- data/README.md +17 -1
- data/Rakefile +17 -91
- data/VERSION +1 -1
- data/ext/json/ext/generator/generator.c +165 -40
- data/ext/json/ext/parser/parser.c +83 -77
- data/ext/json/ext/parser/parser.rl +13 -7
- data/java/src/json/ext/Generator.java +33 -10
- data/json-java.gemspec +4 -5
- data/json.gemspec +0 -0
- data/json_pure.gemspec +9 -14
- data/lib/json.rb +378 -29
- data/lib/json/add/bigdecimal.rb +2 -2
- data/lib/json/add/complex.rb +2 -2
- data/lib/json/add/rational.rb +2 -2
- data/lib/json/add/regexp.rb +2 -2
- data/lib/json/common.rb +326 -91
- data/lib/json/pure/generator.rb +3 -2
- data/lib/json/pure/parser.rb +11 -3
- data/lib/json/version.rb +1 -1
- data/tests/json_common_interface_test.rb +4 -4
- data/tests/json_fixtures_test.rb +6 -1
- data/tests/json_generator_test.rb +44 -0
- data/tests/json_parser_test.rb +14 -14
- metadata +23 -12
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
/* This file is automatically generated from parser.rl by using ragel */
|
2
2
|
#line 1 "parser.rl"
|
3
3
|
#include "../fbuffer/fbuffer.h"
|
4
4
|
#include "parser.h"
|
@@ -27,7 +27,7 @@ enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
|
|
27
27
|
|
28
28
|
/* unicode */
|
29
29
|
|
30
|
-
static const char digit_values[256] = {
|
30
|
+
static const signed char digit_values[256] = {
|
31
31
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
32
32
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
33
33
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
|
@@ -46,7 +46,7 @@ static const char digit_values[256] = {
|
|
46
46
|
|
47
47
|
static UTF32 unescape_unicode(const unsigned char *p)
|
48
48
|
{
|
49
|
-
char b;
|
49
|
+
signed char b;
|
50
50
|
UTF32 result = 0;
|
51
51
|
b = digit_values[p[0]];
|
52
52
|
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
@@ -112,7 +112,7 @@ enum {JSON_object_error = 0};
|
|
112
112
|
enum {JSON_object_en_main = 1};
|
113
113
|
|
114
114
|
|
115
|
-
#line
|
115
|
+
#line 168 "parser.rl"
|
116
116
|
|
117
117
|
|
118
118
|
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
|
@@ -133,7 +133,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
133
133
|
cs = JSON_object_start;
|
134
134
|
}
|
135
135
|
|
136
|
-
#line
|
136
|
+
#line 183 "parser.rl"
|
137
137
|
|
138
138
|
#line 139 "parser.c"
|
139
139
|
{
|
@@ -163,7 +163,7 @@ case 2:
|
|
163
163
|
goto st2;
|
164
164
|
goto st0;
|
165
165
|
tr2:
|
166
|
-
#line
|
166
|
+
#line 150 "parser.rl"
|
167
167
|
{
|
168
168
|
char *np;
|
169
169
|
json->parsing_name = 1;
|
@@ -251,6 +251,7 @@ tr11:
|
|
251
251
|
p--; {p++; cs = 9; goto _out;}
|
252
252
|
} else {
|
253
253
|
if (NIL_P(json->object_class)) {
|
254
|
+
OBJ_FREEZE(last_name);
|
254
255
|
rb_hash_aset(*result, last_name, v);
|
255
256
|
} else {
|
256
257
|
rb_funcall(*result, i_aset, 2, last_name, v);
|
@@ -263,7 +264,7 @@ st9:
|
|
263
264
|
if ( ++p == pe )
|
264
265
|
goto _test_eof9;
|
265
266
|
case 9:
|
266
|
-
#line
|
267
|
+
#line 268 "parser.c"
|
267
268
|
switch( (*p) ) {
|
268
269
|
case 13: goto st9;
|
269
270
|
case 32: goto st9;
|
@@ -352,14 +353,14 @@ case 18:
|
|
352
353
|
goto st9;
|
353
354
|
goto st18;
|
354
355
|
tr4:
|
355
|
-
#line
|
356
|
+
#line 158 "parser.rl"
|
356
357
|
{ p--; {p++; cs = 27; goto _out;} }
|
357
358
|
goto st27;
|
358
359
|
st27:
|
359
360
|
if ( ++p == pe )
|
360
361
|
goto _test_eof27;
|
361
362
|
case 27:
|
362
|
-
#line
|
363
|
+
#line 364 "parser.c"
|
363
364
|
goto st0;
|
364
365
|
st19:
|
365
366
|
if ( ++p == pe )
|
@@ -457,7 +458,7 @@ case 26:
|
|
457
458
|
_out: {}
|
458
459
|
}
|
459
460
|
|
460
|
-
#line
|
461
|
+
#line 184 "parser.rl"
|
461
462
|
|
462
463
|
if (cs >= JSON_object_first_final) {
|
463
464
|
if (json->create_additions) {
|
@@ -482,7 +483,7 @@ case 26:
|
|
482
483
|
|
483
484
|
|
484
485
|
|
485
|
-
#line
|
486
|
+
#line 487 "parser.c"
|
486
487
|
enum {JSON_value_start = 1};
|
487
488
|
enum {JSON_value_first_final = 29};
|
488
489
|
enum {JSON_value_error = 0};
|
@@ -490,7 +491,7 @@ enum {JSON_value_error = 0};
|
|
490
491
|
enum {JSON_value_en_main = 1};
|
491
492
|
|
492
493
|
|
493
|
-
#line
|
494
|
+
#line 284 "parser.rl"
|
494
495
|
|
495
496
|
|
496
497
|
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
|
@@ -498,14 +499,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
498
499
|
int cs = EVIL;
|
499
500
|
|
500
501
|
|
501
|
-
#line
|
502
|
+
#line 503 "parser.c"
|
502
503
|
{
|
503
504
|
cs = JSON_value_start;
|
504
505
|
}
|
505
506
|
|
506
|
-
#line
|
507
|
+
#line 291 "parser.rl"
|
507
508
|
|
508
|
-
#line
|
509
|
+
#line 510 "parser.c"
|
509
510
|
{
|
510
511
|
if ( p == pe )
|
511
512
|
goto _test_eof;
|
@@ -539,14 +540,14 @@ st0:
|
|
539
540
|
cs = 0;
|
540
541
|
goto _out;
|
541
542
|
tr2:
|
542
|
-
#line
|
543
|
+
#line 236 "parser.rl"
|
543
544
|
{
|
544
545
|
char *np = JSON_parse_string(json, p, pe, result);
|
545
546
|
if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
|
546
547
|
}
|
547
548
|
goto st29;
|
548
549
|
tr3:
|
549
|
-
#line
|
550
|
+
#line 241 "parser.rl"
|
550
551
|
{
|
551
552
|
char *np;
|
552
553
|
if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
|
@@ -566,7 +567,7 @@ tr3:
|
|
566
567
|
}
|
567
568
|
goto st29;
|
568
569
|
tr7:
|
569
|
-
#line
|
570
|
+
#line 259 "parser.rl"
|
570
571
|
{
|
571
572
|
char *np;
|
572
573
|
np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
|
@@ -574,7 +575,7 @@ tr7:
|
|
574
575
|
}
|
575
576
|
goto st29;
|
576
577
|
tr11:
|
577
|
-
#line
|
578
|
+
#line 265 "parser.rl"
|
578
579
|
{
|
579
580
|
char *np;
|
580
581
|
np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
|
@@ -582,7 +583,7 @@ tr11:
|
|
582
583
|
}
|
583
584
|
goto st29;
|
584
585
|
tr25:
|
585
|
-
#line
|
586
|
+
#line 229 "parser.rl"
|
586
587
|
{
|
587
588
|
if (json->allow_nan) {
|
588
589
|
*result = CInfinity;
|
@@ -592,7 +593,7 @@ tr25:
|
|
592
593
|
}
|
593
594
|
goto st29;
|
594
595
|
tr27:
|
595
|
-
#line
|
596
|
+
#line 222 "parser.rl"
|
596
597
|
{
|
597
598
|
if (json->allow_nan) {
|
598
599
|
*result = CNaN;
|
@@ -602,19 +603,19 @@ tr27:
|
|
602
603
|
}
|
603
604
|
goto st29;
|
604
605
|
tr31:
|
605
|
-
#line
|
606
|
+
#line 216 "parser.rl"
|
606
607
|
{
|
607
608
|
*result = Qfalse;
|
608
609
|
}
|
609
610
|
goto st29;
|
610
611
|
tr34:
|
611
|
-
#line
|
612
|
+
#line 213 "parser.rl"
|
612
613
|
{
|
613
614
|
*result = Qnil;
|
614
615
|
}
|
615
616
|
goto st29;
|
616
617
|
tr37:
|
617
|
-
#line
|
618
|
+
#line 219 "parser.rl"
|
618
619
|
{
|
619
620
|
*result = Qtrue;
|
620
621
|
}
|
@@ -623,9 +624,9 @@ st29:
|
|
623
624
|
if ( ++p == pe )
|
624
625
|
goto _test_eof29;
|
625
626
|
case 29:
|
626
|
-
#line
|
627
|
+
#line 271 "parser.rl"
|
627
628
|
{ p--; {p++; cs = 29; goto _out;} }
|
628
|
-
#line
|
629
|
+
#line 630 "parser.c"
|
629
630
|
switch( (*p) ) {
|
630
631
|
case 13: goto st29;
|
631
632
|
case 32: goto st29;
|
@@ -866,7 +867,7 @@ case 28:
|
|
866
867
|
_out: {}
|
867
868
|
}
|
868
869
|
|
869
|
-
#line
|
870
|
+
#line 292 "parser.rl"
|
870
871
|
|
871
872
|
if (cs >= JSON_value_first_final) {
|
872
873
|
return p;
|
@@ -876,7 +877,7 @@ case 28:
|
|
876
877
|
}
|
877
878
|
|
878
879
|
|
879
|
-
#line
|
880
|
+
#line 881 "parser.c"
|
880
881
|
enum {JSON_integer_start = 1};
|
881
882
|
enum {JSON_integer_first_final = 3};
|
882
883
|
enum {JSON_integer_error = 0};
|
@@ -884,7 +885,7 @@ enum {JSON_integer_error = 0};
|
|
884
885
|
enum {JSON_integer_en_main = 1};
|
885
886
|
|
886
887
|
|
887
|
-
#line
|
888
|
+
#line 308 "parser.rl"
|
888
889
|
|
889
890
|
|
890
891
|
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
@@ -892,15 +893,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
|
|
892
893
|
int cs = EVIL;
|
893
894
|
|
894
895
|
|
895
|
-
#line
|
896
|
+
#line 897 "parser.c"
|
896
897
|
{
|
897
898
|
cs = JSON_integer_start;
|
898
899
|
}
|
899
900
|
|
900
|
-
#line
|
901
|
+
#line 315 "parser.rl"
|
901
902
|
json->memo = p;
|
902
903
|
|
903
|
-
#line
|
904
|
+
#line 905 "parser.c"
|
904
905
|
{
|
905
906
|
if ( p == pe )
|
906
907
|
goto _test_eof;
|
@@ -934,14 +935,14 @@ case 3:
|
|
934
935
|
goto st0;
|
935
936
|
goto tr4;
|
936
937
|
tr4:
|
937
|
-
#line
|
938
|
+
#line 305 "parser.rl"
|
938
939
|
{ p--; {p++; cs = 4; goto _out;} }
|
939
940
|
goto st4;
|
940
941
|
st4:
|
941
942
|
if ( ++p == pe )
|
942
943
|
goto _test_eof4;
|
943
944
|
case 4:
|
944
|
-
#line
|
945
|
+
#line 946 "parser.c"
|
945
946
|
goto st0;
|
946
947
|
st5:
|
947
948
|
if ( ++p == pe )
|
@@ -960,7 +961,7 @@ case 5:
|
|
960
961
|
_out: {}
|
961
962
|
}
|
962
963
|
|
963
|
-
#line
|
964
|
+
#line 317 "parser.rl"
|
964
965
|
|
965
966
|
if (cs >= JSON_integer_first_final) {
|
966
967
|
long len = p - json->memo;
|
@@ -975,7 +976,7 @@ case 5:
|
|
975
976
|
}
|
976
977
|
|
977
978
|
|
978
|
-
#line
|
979
|
+
#line 980 "parser.c"
|
979
980
|
enum {JSON_float_start = 1};
|
980
981
|
enum {JSON_float_first_final = 8};
|
981
982
|
enum {JSON_float_error = 0};
|
@@ -983,7 +984,7 @@ enum {JSON_float_error = 0};
|
|
983
984
|
enum {JSON_float_en_main = 1};
|
984
985
|
|
985
986
|
|
986
|
-
#line
|
987
|
+
#line 342 "parser.rl"
|
987
988
|
|
988
989
|
|
989
990
|
static int is_bigdecimal_class(VALUE obj)
|
@@ -1004,15 +1005,15 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
1004
1005
|
int cs = EVIL;
|
1005
1006
|
|
1006
1007
|
|
1007
|
-
#line
|
1008
|
+
#line 1009 "parser.c"
|
1008
1009
|
{
|
1009
1010
|
cs = JSON_float_start;
|
1010
1011
|
}
|
1011
1012
|
|
1012
|
-
#line
|
1013
|
+
#line 362 "parser.rl"
|
1013
1014
|
json->memo = p;
|
1014
1015
|
|
1015
|
-
#line
|
1016
|
+
#line 1017 "parser.c"
|
1016
1017
|
{
|
1017
1018
|
if ( p == pe )
|
1018
1019
|
goto _test_eof;
|
@@ -1070,14 +1071,14 @@ case 8:
|
|
1070
1071
|
goto st0;
|
1071
1072
|
goto tr9;
|
1072
1073
|
tr9:
|
1073
|
-
#line
|
1074
|
+
#line 336 "parser.rl"
|
1074
1075
|
{ p--; {p++; cs = 9; goto _out;} }
|
1075
1076
|
goto st9;
|
1076
1077
|
st9:
|
1077
1078
|
if ( ++p == pe )
|
1078
1079
|
goto _test_eof9;
|
1079
1080
|
case 9:
|
1080
|
-
#line
|
1081
|
+
#line 1082 "parser.c"
|
1081
1082
|
goto st0;
|
1082
1083
|
st5:
|
1083
1084
|
if ( ++p == pe )
|
@@ -1138,7 +1139,7 @@ case 7:
|
|
1138
1139
|
_out: {}
|
1139
1140
|
}
|
1140
1141
|
|
1141
|
-
#line
|
1142
|
+
#line 364 "parser.rl"
|
1142
1143
|
|
1143
1144
|
if (cs >= JSON_float_first_final) {
|
1144
1145
|
long len = p - json->memo;
|
@@ -1164,7 +1165,7 @@ case 7:
|
|
1164
1165
|
|
1165
1166
|
|
1166
1167
|
|
1167
|
-
#line
|
1168
|
+
#line 1169 "parser.c"
|
1168
1169
|
enum {JSON_array_start = 1};
|
1169
1170
|
enum {JSON_array_first_final = 17};
|
1170
1171
|
enum {JSON_array_error = 0};
|
@@ -1172,7 +1173,7 @@ enum {JSON_array_error = 0};
|
|
1172
1173
|
enum {JSON_array_en_main = 1};
|
1173
1174
|
|
1174
1175
|
|
1175
|
-
#line
|
1176
|
+
#line 417 "parser.rl"
|
1176
1177
|
|
1177
1178
|
|
1178
1179
|
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
|
@@ -1186,14 +1187,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
1186
1187
|
*result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
|
1187
1188
|
|
1188
1189
|
|
1189
|
-
#line
|
1190
|
+
#line 1191 "parser.c"
|
1190
1191
|
{
|
1191
1192
|
cs = JSON_array_start;
|
1192
1193
|
}
|
1193
1194
|
|
1194
|
-
#line
|
1195
|
+
#line 430 "parser.rl"
|
1195
1196
|
|
1196
|
-
#line
|
1197
|
+
#line 1198 "parser.c"
|
1197
1198
|
{
|
1198
1199
|
if ( p == pe )
|
1199
1200
|
goto _test_eof;
|
@@ -1232,7 +1233,7 @@ case 2:
|
|
1232
1233
|
goto st2;
|
1233
1234
|
goto st0;
|
1234
1235
|
tr2:
|
1235
|
-
#line
|
1236
|
+
#line 394 "parser.rl"
|
1236
1237
|
{
|
1237
1238
|
VALUE v = Qnil;
|
1238
1239
|
char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
|
@@ -1252,7 +1253,7 @@ st3:
|
|
1252
1253
|
if ( ++p == pe )
|
1253
1254
|
goto _test_eof3;
|
1254
1255
|
case 3:
|
1255
|
-
#line
|
1256
|
+
#line 1257 "parser.c"
|
1256
1257
|
switch( (*p) ) {
|
1257
1258
|
case 13: goto st3;
|
1258
1259
|
case 32: goto st3;
|
@@ -1352,14 +1353,14 @@ case 12:
|
|
1352
1353
|
goto st3;
|
1353
1354
|
goto st12;
|
1354
1355
|
tr4:
|
1355
|
-
#line
|
1356
|
+
#line 409 "parser.rl"
|
1356
1357
|
{ p--; {p++; cs = 17; goto _out;} }
|
1357
1358
|
goto st17;
|
1358
1359
|
st17:
|
1359
1360
|
if ( ++p == pe )
|
1360
1361
|
goto _test_eof17;
|
1361
1362
|
case 17:
|
1362
|
-
#line
|
1363
|
+
#line 1364 "parser.c"
|
1363
1364
|
goto st0;
|
1364
1365
|
st13:
|
1365
1366
|
if ( ++p == pe )
|
@@ -1415,7 +1416,7 @@ case 16:
|
|
1415
1416
|
_out: {}
|
1416
1417
|
}
|
1417
1418
|
|
1418
|
-
#line
|
1419
|
+
#line 431 "parser.rl"
|
1419
1420
|
|
1420
1421
|
if(cs >= JSON_array_first_final) {
|
1421
1422
|
return p + 1;
|
@@ -1504,7 +1505,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
|
|
1504
1505
|
}
|
1505
1506
|
|
1506
1507
|
|
1507
|
-
#line
|
1508
|
+
#line 1509 "parser.c"
|
1508
1509
|
enum {JSON_string_start = 1};
|
1509
1510
|
enum {JSON_string_first_final = 8};
|
1510
1511
|
enum {JSON_string_error = 0};
|
@@ -1512,7 +1513,7 @@ enum {JSON_string_error = 0};
|
|
1512
1513
|
enum {JSON_string_en_main = 1};
|
1513
1514
|
|
1514
1515
|
|
1515
|
-
#line
|
1516
|
+
#line 538 "parser.rl"
|
1516
1517
|
|
1517
1518
|
|
1518
1519
|
static int
|
@@ -1534,15 +1535,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
1534
1535
|
|
1535
1536
|
*result = rb_str_buf_new(0);
|
1536
1537
|
|
1537
|
-
#line
|
1538
|
+
#line 1539 "parser.c"
|
1538
1539
|
{
|
1539
1540
|
cs = JSON_string_start;
|
1540
1541
|
}
|
1541
1542
|
|
1542
|
-
#line
|
1543
|
+
#line 559 "parser.rl"
|
1543
1544
|
json->memo = p;
|
1544
1545
|
|
1545
|
-
#line
|
1546
|
+
#line 1547 "parser.c"
|
1546
1547
|
{
|
1547
1548
|
if ( p == pe )
|
1548
1549
|
goto _test_eof;
|
@@ -1563,11 +1564,11 @@ case 2:
|
|
1563
1564
|
case 34: goto tr2;
|
1564
1565
|
case 92: goto st3;
|
1565
1566
|
}
|
1566
|
-
if ( 0 <= (*p) && (*p) <= 31 )
|
1567
|
+
if ( 0 <= (signed char)(*p) && (*p) <= 31 )
|
1567
1568
|
goto st0;
|
1568
1569
|
goto st2;
|
1569
1570
|
tr2:
|
1570
|
-
#line
|
1571
|
+
#line 524 "parser.rl"
|
1571
1572
|
{
|
1572
1573
|
*result = json_string_unescape(*result, json->memo + 1, p);
|
1573
1574
|
if (NIL_P(*result)) {
|
@@ -1578,14 +1579,14 @@ tr2:
|
|
1578
1579
|
{p = (( p + 1))-1;}
|
1579
1580
|
}
|
1580
1581
|
}
|
1581
|
-
#line
|
1582
|
+
#line 535 "parser.rl"
|
1582
1583
|
{ p--; {p++; cs = 8; goto _out;} }
|
1583
1584
|
goto st8;
|
1584
1585
|
st8:
|
1585
1586
|
if ( ++p == pe )
|
1586
1587
|
goto _test_eof8;
|
1587
1588
|
case 8:
|
1588
|
-
#line
|
1589
|
+
#line 1590 "parser.c"
|
1589
1590
|
goto st0;
|
1590
1591
|
st3:
|
1591
1592
|
if ( ++p == pe )
|
@@ -1593,7 +1594,7 @@ st3:
|
|
1593
1594
|
case 3:
|
1594
1595
|
if ( (*p) == 117 )
|
1595
1596
|
goto st4;
|
1596
|
-
if ( 0 <= (*p) && (*p) <= 31 )
|
1597
|
+
if ( 0 <= (signed char)(*p) && (*p) <= 31 )
|
1597
1598
|
goto st0;
|
1598
1599
|
goto st2;
|
1599
1600
|
st4:
|
@@ -1661,7 +1662,7 @@ case 7:
|
|
1661
1662
|
_out: {}
|
1662
1663
|
}
|
1663
1664
|
|
1664
|
-
#line
|
1665
|
+
#line 561 "parser.rl"
|
1665
1666
|
|
1666
1667
|
if (json->create_additions && RTEST(match_string = json->match_string)) {
|
1667
1668
|
VALUE klass;
|
@@ -1676,10 +1677,8 @@ case 7:
|
|
1676
1677
|
|
1677
1678
|
if (json->symbolize_names && json->parsing_name) {
|
1678
1679
|
*result = rb_str_intern(*result);
|
1679
|
-
} else {
|
1680
|
-
|
1681
|
-
rb_str_resize(*result, RSTRING_LEN(*result));
|
1682
|
-
}
|
1680
|
+
} else if (RB_TYPE_P(*result, T_STRING)) {
|
1681
|
+
rb_str_resize(*result, RSTRING_LEN(*result));
|
1683
1682
|
}
|
1684
1683
|
if (cs >= JSON_string_first_final) {
|
1685
1684
|
return p + 1;
|
@@ -1835,7 +1834,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|
1835
1834
|
} else {
|
1836
1835
|
json->max_nesting = 100;
|
1837
1836
|
json->allow_nan = 0;
|
1838
|
-
json->create_additions =
|
1837
|
+
json->create_additions = 0;
|
1839
1838
|
json->create_id = rb_funcall(mJSON, i_create_id, 0);
|
1840
1839
|
json->object_class = Qnil;
|
1841
1840
|
json->array_class = Qnil;
|
@@ -1850,7 +1849,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|
1850
1849
|
}
|
1851
1850
|
|
1852
1851
|
|
1853
|
-
#line
|
1852
|
+
#line 1853 "parser.c"
|
1854
1853
|
enum {JSON_start = 1};
|
1855
1854
|
enum {JSON_first_final = 10};
|
1856
1855
|
enum {JSON_error = 0};
|
@@ -1858,7 +1857,7 @@ enum {JSON_error = 0};
|
|
1858
1857
|
enum {JSON_en_main = 1};
|
1859
1858
|
|
1860
1859
|
|
1861
|
-
#line
|
1860
|
+
#line 761 "parser.rl"
|
1862
1861
|
|
1863
1862
|
|
1864
1863
|
/*
|
@@ -1875,16 +1874,16 @@ static VALUE cParser_parse(VALUE self)
|
|
1875
1874
|
GET_PARSER;
|
1876
1875
|
|
1877
1876
|
|
1878
|
-
#line
|
1877
|
+
#line 1878 "parser.c"
|
1879
1878
|
{
|
1880
1879
|
cs = JSON_start;
|
1881
1880
|
}
|
1882
1881
|
|
1883
|
-
#line
|
1882
|
+
#line 777 "parser.rl"
|
1884
1883
|
p = json->source;
|
1885
1884
|
pe = p + json->len;
|
1886
1885
|
|
1887
|
-
#line
|
1886
|
+
#line 1887 "parser.c"
|
1888
1887
|
{
|
1889
1888
|
if ( p == pe )
|
1890
1889
|
goto _test_eof;
|
@@ -1918,7 +1917,7 @@ st0:
|
|
1918
1917
|
cs = 0;
|
1919
1918
|
goto _out;
|
1920
1919
|
tr2:
|
1921
|
-
#line
|
1920
|
+
#line 753 "parser.rl"
|
1922
1921
|
{
|
1923
1922
|
char *np = JSON_parse_value(json, p, pe, &result, 0);
|
1924
1923
|
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
|
@@ -1928,7 +1927,7 @@ st10:
|
|
1928
1927
|
if ( ++p == pe )
|
1929
1928
|
goto _test_eof10;
|
1930
1929
|
case 10:
|
1931
|
-
#line
|
1930
|
+
#line 1931 "parser.c"
|
1932
1931
|
switch( (*p) ) {
|
1933
1932
|
case 13: goto st10;
|
1934
1933
|
case 32: goto st10;
|
@@ -2017,7 +2016,7 @@ case 9:
|
|
2017
2016
|
_out: {}
|
2018
2017
|
}
|
2019
2018
|
|
2020
|
-
#line
|
2019
|
+
#line 780 "parser.rl"
|
2021
2020
|
|
2022
2021
|
if (cs >= JSON_first_final && p == pe) {
|
2023
2022
|
return result;
|
@@ -2091,14 +2090,21 @@ void Init_parser(void)
|
|
2091
2090
|
cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
|
2092
2091
|
eParserError = rb_path2class("JSON::ParserError");
|
2093
2092
|
eNestingError = rb_path2class("JSON::NestingError");
|
2093
|
+
rb_gc_register_mark_object(eParserError);
|
2094
|
+
rb_gc_register_mark_object(eNestingError);
|
2094
2095
|
rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
|
2095
2096
|
rb_define_method(cParser, "initialize", cParser_initialize, -1);
|
2096
2097
|
rb_define_method(cParser, "parse", cParser_parse, 0);
|
2097
2098
|
rb_define_method(cParser, "source", cParser_source, 0);
|
2098
2099
|
|
2099
2100
|
CNaN = rb_const_get(mJSON, rb_intern("NaN"));
|
2101
|
+
rb_gc_register_mark_object(CNaN);
|
2102
|
+
|
2100
2103
|
CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
|
2104
|
+
rb_gc_register_mark_object(CInfinity);
|
2105
|
+
|
2101
2106
|
CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
|
2107
|
+
rb_gc_register_mark_object(CMinusInfinity);
|
2102
2108
|
|
2103
2109
|
i_json_creatable_p = rb_intern("json_creatable?");
|
2104
2110
|
i_json_create = rb_intern("json_create");
|