json_pure 1.2.4 → 1.4.6
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.
- data/CHANGES +32 -0
- data/README +14 -18
- data/Rakefile +19 -14
- data/VERSION +1 -1
- data/benchmarks/generator2_benchmark.rb +222 -0
- data/benchmarks/generator_benchmark.rb +63 -4
- data/benchmarks/ohai.json +1216 -0
- data/benchmarks/ohai.ruby +1 -0
- data/benchmarks/parser2_benchmark.rb +251 -0
- data/benchmarks/parser_benchmark.rb +52 -4
- data/ext/json/ext/generator/extconf.rb +14 -5
- data/ext/json/ext/generator/generator.c +880 -416
- data/ext/json/ext/generator/generator.h +197 -0
- data/ext/json/ext/parser/extconf.rb +8 -4
- data/ext/json/ext/parser/parser.c +225 -183
- data/ext/json/ext/parser/parser.h +71 -0
- data/ext/json/ext/parser/parser.rl +151 -109
- data/lib/json/common.rb +53 -42
- data/lib/json/pure/generator.rb +111 -120
- data/lib/json/pure/parser.rb +29 -27
- data/lib/json/version.rb +1 -1
- data/tests/test_json.rb +70 -3
- data/tests/test_json_addition.rb +6 -6
- data/tests/test_json_encoding.rb +4 -3
- data/tests/test_json_generate.rb +66 -7
- data/tests/test_json_unicode.rb +20 -6
- metadata +10 -8
- data/ext/json/ext/generator/unicode.c +0 -180
- data/ext/json/ext/generator/unicode.h +0 -53
- data/ext/json/ext/parser/unicode.c +0 -154
- data/ext/json/ext/parser/unicode.h +0 -58
|
@@ -1,23 +1,76 @@
|
|
|
1
1
|
|
|
2
2
|
#line 1 "parser.rl"
|
|
3
|
-
#include "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
#include "parser.h"
|
|
4
|
+
|
|
5
|
+
/* unicode */
|
|
6
|
+
|
|
7
|
+
static const char digit_values[256] = {
|
|
8
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
9
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
10
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
|
|
11
|
+
-1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
|
|
12
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
13
|
+
10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
14
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
15
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
16
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
17
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
18
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
19
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
20
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
21
|
+
-1, -1, -1, -1, -1, -1, -1
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
static UTF32 unescape_unicode(const unsigned char *p)
|
|
25
|
+
{
|
|
26
|
+
char b;
|
|
27
|
+
UTF32 result = 0;
|
|
28
|
+
b = digit_values[p[0]];
|
|
29
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
|
30
|
+
result = (result << 4) | b;
|
|
31
|
+
b = digit_values[p[1]];
|
|
32
|
+
result = (result << 4) | b;
|
|
33
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
|
34
|
+
b = digit_values[p[2]];
|
|
35
|
+
result = (result << 4) | b;
|
|
36
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
|
37
|
+
b = digit_values[p[3]];
|
|
38
|
+
result = (result << 4) | b;
|
|
39
|
+
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
10
42
|
|
|
11
|
-
|
|
43
|
+
static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
|
|
44
|
+
{
|
|
45
|
+
int len = 1;
|
|
46
|
+
if (ch <= 0x7F) {
|
|
47
|
+
buf[0] = (char) ch;
|
|
48
|
+
} else if (ch <= 0x07FF) {
|
|
49
|
+
buf[0] = (char) ((ch >> 6) | 0xC0);
|
|
50
|
+
buf[1] = (char) ((ch & 0x3F) | 0x80);
|
|
51
|
+
len++;
|
|
52
|
+
} else if (ch <= 0xFFFF) {
|
|
53
|
+
buf[0] = (char) ((ch >> 12) | 0xE0);
|
|
54
|
+
buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
|
|
55
|
+
buf[2] = (char) ((ch & 0x3F) | 0x80);
|
|
56
|
+
len += 2;
|
|
57
|
+
} else if (ch <= 0x1fffff) {
|
|
58
|
+
buf[0] =(char) ((ch >> 18) | 0xF0);
|
|
59
|
+
buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
|
|
60
|
+
buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
|
|
61
|
+
buf[3] =(char) ((ch & 0x3F) | 0x80);
|
|
62
|
+
len += 3;
|
|
63
|
+
} else {
|
|
64
|
+
buf[0] = '?';
|
|
65
|
+
}
|
|
66
|
+
return len;
|
|
67
|
+
}
|
|
12
68
|
|
|
13
69
|
#ifdef HAVE_RUBY_ENCODING_H
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
static VALUE mEncoding_ASCII_8BIT, mEncoding_UTF_8, mEncoding_UTF_16BE,
|
|
17
|
-
mEncoding_UTF_16LE, mEncoding_UTF_32BE, mEncoding_UTF_32LE;
|
|
70
|
+
static VALUE CEncoding_ASCII_8BIT, CEncoding_UTF_8, CEncoding_UTF_16BE,
|
|
71
|
+
CEncoding_UTF_16LE, CEncoding_UTF_32BE, CEncoding_UTF_32LE;
|
|
18
72
|
static ID i_encoding, i_encode, i_encode_bang, i_force_encoding;
|
|
19
73
|
#else
|
|
20
|
-
#define FORCE_UTF8(obj)
|
|
21
74
|
static ID i_iconv;
|
|
22
75
|
#endif
|
|
23
76
|
|
|
@@ -28,40 +81,12 @@ static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
|
|
|
28
81
|
i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_object_class,
|
|
29
82
|
i_array_class, i_key_p, i_deep_const_get;
|
|
30
83
|
|
|
31
|
-
#define MinusInfinity "-Infinity"
|
|
32
|
-
|
|
33
|
-
typedef struct JSON_ParserStruct {
|
|
34
|
-
VALUE Vsource;
|
|
35
|
-
char *source;
|
|
36
|
-
long len;
|
|
37
|
-
char *memo;
|
|
38
|
-
VALUE create_id;
|
|
39
|
-
int max_nesting;
|
|
40
|
-
int current_nesting;
|
|
41
|
-
int allow_nan;
|
|
42
|
-
int parsing_name;
|
|
43
|
-
int symbolize_names;
|
|
44
|
-
VALUE object_class;
|
|
45
|
-
VALUE array_class;
|
|
46
|
-
} JSON_Parser;
|
|
47
84
|
|
|
48
|
-
|
|
49
|
-
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
50
|
-
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
51
|
-
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
52
|
-
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
53
|
-
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
|
85
|
+
#line 108 "parser.rl"
|
|
54
86
|
|
|
55
|
-
#define GET_STRUCT \
|
|
56
|
-
JSON_Parser *json; \
|
|
57
|
-
Data_Get_Struct(self, JSON_Parser, json);
|
|
58
87
|
|
|
59
88
|
|
|
60
|
-
#line
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
#line 65 "parser.c"
|
|
89
|
+
#line 90 "parser.c"
|
|
65
90
|
static const int JSON_object_start = 1;
|
|
66
91
|
static const int JSON_object_first_final = 27;
|
|
67
92
|
static const int JSON_object_error = 0;
|
|
@@ -69,7 +94,7 @@ static const int JSON_object_error = 0;
|
|
|
69
94
|
static const int JSON_object_en_main = 1;
|
|
70
95
|
|
|
71
96
|
|
|
72
|
-
#line
|
|
97
|
+
#line 143 "parser.rl"
|
|
73
98
|
|
|
74
99
|
|
|
75
100
|
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
@@ -85,14 +110,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
|
85
110
|
*result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
|
|
86
111
|
|
|
87
112
|
|
|
88
|
-
#line
|
|
113
|
+
#line 114 "parser.c"
|
|
89
114
|
{
|
|
90
115
|
cs = JSON_object_start;
|
|
91
116
|
}
|
|
92
117
|
|
|
93
|
-
#line
|
|
118
|
+
#line 158 "parser.rl"
|
|
94
119
|
|
|
95
|
-
#line
|
|
120
|
+
#line 121 "parser.c"
|
|
96
121
|
{
|
|
97
122
|
if ( p == pe )
|
|
98
123
|
goto _test_eof;
|
|
@@ -120,10 +145,11 @@ case 2:
|
|
|
120
145
|
goto st2;
|
|
121
146
|
goto st0;
|
|
122
147
|
tr2:
|
|
123
|
-
#line
|
|
148
|
+
#line 127 "parser.rl"
|
|
124
149
|
{
|
|
150
|
+
char *np;
|
|
125
151
|
json->parsing_name = 1;
|
|
126
|
-
|
|
152
|
+
np = JSON_parse_string(json, p, pe, &last_name);
|
|
127
153
|
json->parsing_name = 0;
|
|
128
154
|
if (np == NULL) { p--; {p++; cs = 3; goto _out;} } else {p = (( np))-1;}
|
|
129
155
|
}
|
|
@@ -132,7 +158,7 @@ st3:
|
|
|
132
158
|
if ( ++p == pe )
|
|
133
159
|
goto _test_eof3;
|
|
134
160
|
case 3:
|
|
135
|
-
#line
|
|
161
|
+
#line 161 "parser.c"
|
|
136
162
|
switch( (*p) ) {
|
|
137
163
|
case 13: goto st3;
|
|
138
164
|
case 32: goto st3;
|
|
@@ -199,7 +225,7 @@ case 8:
|
|
|
199
225
|
goto st8;
|
|
200
226
|
goto st0;
|
|
201
227
|
tr11:
|
|
202
|
-
#line
|
|
228
|
+
#line 116 "parser.rl"
|
|
203
229
|
{
|
|
204
230
|
VALUE v = Qnil;
|
|
205
231
|
char *np = JSON_parse_value(json, p, pe, &v);
|
|
@@ -215,7 +241,7 @@ st9:
|
|
|
215
241
|
if ( ++p == pe )
|
|
216
242
|
goto _test_eof9;
|
|
217
243
|
case 9:
|
|
218
|
-
#line
|
|
244
|
+
#line 244 "parser.c"
|
|
219
245
|
switch( (*p) ) {
|
|
220
246
|
case 13: goto st9;
|
|
221
247
|
case 32: goto st9;
|
|
@@ -304,14 +330,14 @@ case 18:
|
|
|
304
330
|
goto st9;
|
|
305
331
|
goto st18;
|
|
306
332
|
tr4:
|
|
307
|
-
#line
|
|
333
|
+
#line 134 "parser.rl"
|
|
308
334
|
{ p--; {p++; cs = 27; goto _out;} }
|
|
309
335
|
goto st27;
|
|
310
336
|
st27:
|
|
311
337
|
if ( ++p == pe )
|
|
312
338
|
goto _test_eof27;
|
|
313
339
|
case 27:
|
|
314
|
-
#line
|
|
340
|
+
#line 340 "parser.c"
|
|
315
341
|
goto st0;
|
|
316
342
|
st19:
|
|
317
343
|
if ( ++p == pe )
|
|
@@ -409,7 +435,7 @@ case 26:
|
|
|
409
435
|
_out: {}
|
|
410
436
|
}
|
|
411
437
|
|
|
412
|
-
#line
|
|
438
|
+
#line 159 "parser.rl"
|
|
413
439
|
|
|
414
440
|
if (cs >= JSON_object_first_final) {
|
|
415
441
|
if (RTEST(json->create_id)) {
|
|
@@ -428,7 +454,7 @@ case 26:
|
|
|
428
454
|
}
|
|
429
455
|
|
|
430
456
|
|
|
431
|
-
#line
|
|
457
|
+
#line 457 "parser.c"
|
|
432
458
|
static const int JSON_value_start = 1;
|
|
433
459
|
static const int JSON_value_first_final = 21;
|
|
434
460
|
static const int JSON_value_error = 0;
|
|
@@ -436,7 +462,7 @@ static const int JSON_value_error = 0;
|
|
|
436
462
|
static const int JSON_value_en_main = 1;
|
|
437
463
|
|
|
438
464
|
|
|
439
|
-
#line
|
|
465
|
+
#line 257 "parser.rl"
|
|
440
466
|
|
|
441
467
|
|
|
442
468
|
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
@@ -444,14 +470,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
|
444
470
|
int cs = EVIL;
|
|
445
471
|
|
|
446
472
|
|
|
447
|
-
#line
|
|
473
|
+
#line 473 "parser.c"
|
|
448
474
|
{
|
|
449
475
|
cs = JSON_value_start;
|
|
450
476
|
}
|
|
451
477
|
|
|
452
|
-
#line
|
|
478
|
+
#line 264 "parser.rl"
|
|
453
479
|
|
|
454
|
-
#line
|
|
480
|
+
#line 480 "parser.c"
|
|
455
481
|
{
|
|
456
482
|
if ( p == pe )
|
|
457
483
|
goto _test_eof;
|
|
@@ -476,14 +502,14 @@ st0:
|
|
|
476
502
|
cs = 0;
|
|
477
503
|
goto _out;
|
|
478
504
|
tr0:
|
|
479
|
-
#line
|
|
505
|
+
#line 205 "parser.rl"
|
|
480
506
|
{
|
|
481
507
|
char *np = JSON_parse_string(json, p, pe, result);
|
|
482
508
|
if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;}
|
|
483
509
|
}
|
|
484
510
|
goto st21;
|
|
485
511
|
tr2:
|
|
486
|
-
#line
|
|
512
|
+
#line 210 "parser.rl"
|
|
487
513
|
{
|
|
488
514
|
char *np;
|
|
489
515
|
if(pe > p + 9 && !strncmp(MinusInfinity, p, 9)) {
|
|
@@ -503,7 +529,7 @@ tr2:
|
|
|
503
529
|
}
|
|
504
530
|
goto st21;
|
|
505
531
|
tr5:
|
|
506
|
-
#line
|
|
532
|
+
#line 228 "parser.rl"
|
|
507
533
|
{
|
|
508
534
|
char *np;
|
|
509
535
|
json->current_nesting++;
|
|
@@ -513,7 +539,7 @@ tr5:
|
|
|
513
539
|
}
|
|
514
540
|
goto st21;
|
|
515
541
|
tr9:
|
|
516
|
-
#line
|
|
542
|
+
#line 236 "parser.rl"
|
|
517
543
|
{
|
|
518
544
|
char *np;
|
|
519
545
|
json->current_nesting++;
|
|
@@ -523,7 +549,7 @@ tr9:
|
|
|
523
549
|
}
|
|
524
550
|
goto st21;
|
|
525
551
|
tr16:
|
|
526
|
-
#line
|
|
552
|
+
#line 198 "parser.rl"
|
|
527
553
|
{
|
|
528
554
|
if (json->allow_nan) {
|
|
529
555
|
*result = CInfinity;
|
|
@@ -533,7 +559,7 @@ tr16:
|
|
|
533
559
|
}
|
|
534
560
|
goto st21;
|
|
535
561
|
tr18:
|
|
536
|
-
#line
|
|
562
|
+
#line 191 "parser.rl"
|
|
537
563
|
{
|
|
538
564
|
if (json->allow_nan) {
|
|
539
565
|
*result = CNaN;
|
|
@@ -543,19 +569,19 @@ tr18:
|
|
|
543
569
|
}
|
|
544
570
|
goto st21;
|
|
545
571
|
tr22:
|
|
546
|
-
#line
|
|
572
|
+
#line 185 "parser.rl"
|
|
547
573
|
{
|
|
548
574
|
*result = Qfalse;
|
|
549
575
|
}
|
|
550
576
|
goto st21;
|
|
551
577
|
tr25:
|
|
552
|
-
#line
|
|
578
|
+
#line 182 "parser.rl"
|
|
553
579
|
{
|
|
554
580
|
*result = Qnil;
|
|
555
581
|
}
|
|
556
582
|
goto st21;
|
|
557
583
|
tr28:
|
|
558
|
-
#line
|
|
584
|
+
#line 188 "parser.rl"
|
|
559
585
|
{
|
|
560
586
|
*result = Qtrue;
|
|
561
587
|
}
|
|
@@ -564,9 +590,9 @@ st21:
|
|
|
564
590
|
if ( ++p == pe )
|
|
565
591
|
goto _test_eof21;
|
|
566
592
|
case 21:
|
|
567
|
-
#line
|
|
593
|
+
#line 244 "parser.rl"
|
|
568
594
|
{ p--; {p++; cs = 21; goto _out;} }
|
|
569
|
-
#line
|
|
595
|
+
#line 595 "parser.c"
|
|
570
596
|
goto st0;
|
|
571
597
|
st2:
|
|
572
598
|
if ( ++p == pe )
|
|
@@ -727,7 +753,7 @@ case 20:
|
|
|
727
753
|
_out: {}
|
|
728
754
|
}
|
|
729
755
|
|
|
730
|
-
#line
|
|
756
|
+
#line 265 "parser.rl"
|
|
731
757
|
|
|
732
758
|
if (cs >= JSON_value_first_final) {
|
|
733
759
|
return p;
|
|
@@ -737,7 +763,7 @@ case 20:
|
|
|
737
763
|
}
|
|
738
764
|
|
|
739
765
|
|
|
740
|
-
#line
|
|
766
|
+
#line 766 "parser.c"
|
|
741
767
|
static const int JSON_integer_start = 1;
|
|
742
768
|
static const int JSON_integer_first_final = 5;
|
|
743
769
|
static const int JSON_integer_error = 0;
|
|
@@ -745,7 +771,7 @@ static const int JSON_integer_error = 0;
|
|
|
745
771
|
static const int JSON_integer_en_main = 1;
|
|
746
772
|
|
|
747
773
|
|
|
748
|
-
#line
|
|
774
|
+
#line 281 "parser.rl"
|
|
749
775
|
|
|
750
776
|
|
|
751
777
|
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
@@ -753,15 +779,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
|
|
|
753
779
|
int cs = EVIL;
|
|
754
780
|
|
|
755
781
|
|
|
756
|
-
#line
|
|
782
|
+
#line 782 "parser.c"
|
|
757
783
|
{
|
|
758
784
|
cs = JSON_integer_start;
|
|
759
785
|
}
|
|
760
786
|
|
|
761
|
-
#line
|
|
787
|
+
#line 288 "parser.rl"
|
|
762
788
|
json->memo = p;
|
|
763
789
|
|
|
764
|
-
#line
|
|
790
|
+
#line 790 "parser.c"
|
|
765
791
|
{
|
|
766
792
|
if ( p == pe )
|
|
767
793
|
goto _test_eof;
|
|
@@ -795,14 +821,14 @@ case 3:
|
|
|
795
821
|
goto st0;
|
|
796
822
|
goto tr4;
|
|
797
823
|
tr4:
|
|
798
|
-
#line
|
|
824
|
+
#line 278 "parser.rl"
|
|
799
825
|
{ p--; {p++; cs = 5; goto _out;} }
|
|
800
826
|
goto st5;
|
|
801
827
|
st5:
|
|
802
828
|
if ( ++p == pe )
|
|
803
829
|
goto _test_eof5;
|
|
804
830
|
case 5:
|
|
805
|
-
#line
|
|
831
|
+
#line 831 "parser.c"
|
|
806
832
|
goto st0;
|
|
807
833
|
st4:
|
|
808
834
|
if ( ++p == pe )
|
|
@@ -821,7 +847,7 @@ case 4:
|
|
|
821
847
|
_out: {}
|
|
822
848
|
}
|
|
823
849
|
|
|
824
|
-
#line
|
|
850
|
+
#line 290 "parser.rl"
|
|
825
851
|
|
|
826
852
|
if (cs >= JSON_integer_first_final) {
|
|
827
853
|
long len = p - json->memo;
|
|
@@ -833,7 +859,7 @@ case 4:
|
|
|
833
859
|
}
|
|
834
860
|
|
|
835
861
|
|
|
836
|
-
#line
|
|
862
|
+
#line 862 "parser.c"
|
|
837
863
|
static const int JSON_float_start = 1;
|
|
838
864
|
static const int JSON_float_first_final = 10;
|
|
839
865
|
static const int JSON_float_error = 0;
|
|
@@ -841,7 +867,7 @@ static const int JSON_float_error = 0;
|
|
|
841
867
|
static const int JSON_float_en_main = 1;
|
|
842
868
|
|
|
843
869
|
|
|
844
|
-
#line
|
|
870
|
+
#line 312 "parser.rl"
|
|
845
871
|
|
|
846
872
|
|
|
847
873
|
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
@@ -849,15 +875,15 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
|
849
875
|
int cs = EVIL;
|
|
850
876
|
|
|
851
877
|
|
|
852
|
-
#line
|
|
878
|
+
#line 878 "parser.c"
|
|
853
879
|
{
|
|
854
880
|
cs = JSON_float_start;
|
|
855
881
|
}
|
|
856
882
|
|
|
857
|
-
#line
|
|
883
|
+
#line 319 "parser.rl"
|
|
858
884
|
json->memo = p;
|
|
859
885
|
|
|
860
|
-
#line
|
|
886
|
+
#line 886 "parser.c"
|
|
861
887
|
{
|
|
862
888
|
if ( p == pe )
|
|
863
889
|
goto _test_eof;
|
|
@@ -915,14 +941,14 @@ case 5:
|
|
|
915
941
|
goto st0;
|
|
916
942
|
goto tr7;
|
|
917
943
|
tr7:
|
|
918
|
-
#line
|
|
944
|
+
#line 306 "parser.rl"
|
|
919
945
|
{ p--; {p++; cs = 10; goto _out;} }
|
|
920
946
|
goto st10;
|
|
921
947
|
st10:
|
|
922
948
|
if ( ++p == pe )
|
|
923
949
|
goto _test_eof10;
|
|
924
950
|
case 10:
|
|
925
|
-
#line
|
|
951
|
+
#line 951 "parser.c"
|
|
926
952
|
goto st0;
|
|
927
953
|
st6:
|
|
928
954
|
if ( ++p == pe )
|
|
@@ -983,7 +1009,7 @@ case 9:
|
|
|
983
1009
|
_out: {}
|
|
984
1010
|
}
|
|
985
1011
|
|
|
986
|
-
#line
|
|
1012
|
+
#line 321 "parser.rl"
|
|
987
1013
|
|
|
988
1014
|
if (cs >= JSON_float_first_final) {
|
|
989
1015
|
long len = p - json->memo;
|
|
@@ -996,7 +1022,7 @@ case 9:
|
|
|
996
1022
|
|
|
997
1023
|
|
|
998
1024
|
|
|
999
|
-
#line
|
|
1025
|
+
#line 1025 "parser.c"
|
|
1000
1026
|
static const int JSON_array_start = 1;
|
|
1001
1027
|
static const int JSON_array_first_final = 17;
|
|
1002
1028
|
static const int JSON_array_error = 0;
|
|
@@ -1004,7 +1030,7 @@ static const int JSON_array_error = 0;
|
|
|
1004
1030
|
static const int JSON_array_en_main = 1;
|
|
1005
1031
|
|
|
1006
1032
|
|
|
1007
|
-
#line
|
|
1033
|
+
#line 357 "parser.rl"
|
|
1008
1034
|
|
|
1009
1035
|
|
|
1010
1036
|
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
@@ -1018,14 +1044,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
|
1018
1044
|
*result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
|
|
1019
1045
|
|
|
1020
1046
|
|
|
1021
|
-
#line
|
|
1047
|
+
#line 1047 "parser.c"
|
|
1022
1048
|
{
|
|
1023
1049
|
cs = JSON_array_start;
|
|
1024
1050
|
}
|
|
1025
1051
|
|
|
1026
|
-
#line
|
|
1052
|
+
#line 370 "parser.rl"
|
|
1027
1053
|
|
|
1028
|
-
#line
|
|
1054
|
+
#line 1054 "parser.c"
|
|
1029
1055
|
{
|
|
1030
1056
|
if ( p == pe )
|
|
1031
1057
|
goto _test_eof;
|
|
@@ -1064,7 +1090,7 @@ case 2:
|
|
|
1064
1090
|
goto st2;
|
|
1065
1091
|
goto st0;
|
|
1066
1092
|
tr2:
|
|
1067
|
-
#line
|
|
1093
|
+
#line 338 "parser.rl"
|
|
1068
1094
|
{
|
|
1069
1095
|
VALUE v = Qnil;
|
|
1070
1096
|
char *np = JSON_parse_value(json, p, pe, &v);
|
|
@@ -1080,7 +1106,7 @@ st3:
|
|
|
1080
1106
|
if ( ++p == pe )
|
|
1081
1107
|
goto _test_eof3;
|
|
1082
1108
|
case 3:
|
|
1083
|
-
#line
|
|
1109
|
+
#line 1109 "parser.c"
|
|
1084
1110
|
switch( (*p) ) {
|
|
1085
1111
|
case 13: goto st3;
|
|
1086
1112
|
case 32: goto st3;
|
|
@@ -1180,14 +1206,14 @@ case 12:
|
|
|
1180
1206
|
goto st3;
|
|
1181
1207
|
goto st12;
|
|
1182
1208
|
tr4:
|
|
1183
|
-
#line
|
|
1209
|
+
#line 349 "parser.rl"
|
|
1184
1210
|
{ p--; {p++; cs = 17; goto _out;} }
|
|
1185
1211
|
goto st17;
|
|
1186
1212
|
st17:
|
|
1187
1213
|
if ( ++p == pe )
|
|
1188
1214
|
goto _test_eof17;
|
|
1189
1215
|
case 17:
|
|
1190
|
-
#line
|
|
1216
|
+
#line 1216 "parser.c"
|
|
1191
1217
|
goto st0;
|
|
1192
1218
|
st13:
|
|
1193
1219
|
if ( ++p == pe )
|
|
@@ -1243,73 +1269,88 @@ case 16:
|
|
|
1243
1269
|
_out: {}
|
|
1244
1270
|
}
|
|
1245
1271
|
|
|
1246
|
-
#line
|
|
1272
|
+
#line 371 "parser.rl"
|
|
1247
1273
|
|
|
1248
1274
|
if(cs >= JSON_array_first_final) {
|
|
1249
1275
|
return p + 1;
|
|
1250
1276
|
} else {
|
|
1251
1277
|
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p);
|
|
1278
|
+
return NULL;
|
|
1252
1279
|
}
|
|
1253
1280
|
}
|
|
1254
1281
|
|
|
1255
|
-
static VALUE json_string_unescape(char *
|
|
1282
|
+
static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
|
|
1256
1283
|
{
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1284
|
+
char *p = string, *pe = string, *unescape;
|
|
1285
|
+
int unescape_len;
|
|
1286
|
+
|
|
1287
|
+
while (pe < stringEnd) {
|
|
1288
|
+
if (*pe == '\\') {
|
|
1289
|
+
unescape = (char *) "?";
|
|
1290
|
+
unescape_len = 1;
|
|
1291
|
+
if (pe > p) rb_str_buf_cat(result, p, pe - p);
|
|
1292
|
+
switch (*++pe) {
|
|
1293
|
+
case 'n':
|
|
1294
|
+
unescape = (char *) "\n";
|
|
1295
|
+
break;
|
|
1296
|
+
case 'r':
|
|
1297
|
+
unescape = (char *) "\r";
|
|
1298
|
+
break;
|
|
1299
|
+
case 't':
|
|
1300
|
+
unescape = (char *) "\t";
|
|
1301
|
+
break;
|
|
1264
1302
|
case '"':
|
|
1303
|
+
unescape = (char *) "\"";
|
|
1304
|
+
break;
|
|
1265
1305
|
case '\\':
|
|
1266
|
-
|
|
1267
|
-
p++;
|
|
1306
|
+
unescape = (char *) "\\";
|
|
1268
1307
|
break;
|
|
1269
1308
|
case 'b':
|
|
1270
|
-
|
|
1271
|
-
p++;
|
|
1309
|
+
unescape = (char *) "\b";
|
|
1272
1310
|
break;
|
|
1273
1311
|
case 'f':
|
|
1274
|
-
|
|
1275
|
-
p++;
|
|
1276
|
-
break;
|
|
1277
|
-
case 'n':
|
|
1278
|
-
rb_str_buf_cat2(result, "\n");
|
|
1279
|
-
p++;
|
|
1280
|
-
break;
|
|
1281
|
-
case 'r':
|
|
1282
|
-
rb_str_buf_cat2(result, "\r");
|
|
1283
|
-
p++;
|
|
1284
|
-
break;
|
|
1285
|
-
case 't':
|
|
1286
|
-
rb_str_buf_cat2(result, "\t");
|
|
1287
|
-
p++;
|
|
1312
|
+
unescape = (char *) "\f";
|
|
1288
1313
|
break;
|
|
1289
1314
|
case 'u':
|
|
1290
|
-
if (
|
|
1315
|
+
if (pe > stringEnd - 4) {
|
|
1291
1316
|
return Qnil;
|
|
1292
1317
|
} else {
|
|
1293
|
-
|
|
1318
|
+
char buf[4];
|
|
1319
|
+
UTF32 ch = unescape_unicode((unsigned char *) ++pe);
|
|
1320
|
+
pe += 3;
|
|
1321
|
+
if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
|
|
1322
|
+
pe++;
|
|
1323
|
+
if (pe > stringEnd - 6) return Qnil;
|
|
1324
|
+
if (pe[0] == '\\' && pe[1] == 'u') {
|
|
1325
|
+
UTF32 sur = unescape_unicode((unsigned char *) pe + 2);
|
|
1326
|
+
ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
|
|
1327
|
+
| (sur & 0x3FF));
|
|
1328
|
+
pe += 5;
|
|
1329
|
+
} else {
|
|
1330
|
+
unescape = (char *) "?";
|
|
1331
|
+
break;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
unescape_len = convert_UTF32_to_UTF8(buf, ch);
|
|
1335
|
+
unescape = buf;
|
|
1294
1336
|
}
|
|
1295
1337
|
break;
|
|
1296
1338
|
default:
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
break;
|
|
1339
|
+
p = pe;
|
|
1340
|
+
continue;
|
|
1300
1341
|
}
|
|
1342
|
+
rb_str_buf_cat(result, unescape, unescape_len);
|
|
1343
|
+
p = ++pe;
|
|
1301
1344
|
} else {
|
|
1302
|
-
|
|
1303
|
-
while (*q != '\\' && q < pe) q++;
|
|
1304
|
-
rb_str_buf_cat(result, p, q - p);
|
|
1305
|
-
p = q;
|
|
1345
|
+
pe++;
|
|
1306
1346
|
}
|
|
1307
1347
|
}
|
|
1348
|
+
rb_str_buf_cat(result, p, pe - p);
|
|
1308
1349
|
return result;
|
|
1309
1350
|
}
|
|
1310
1351
|
|
|
1311
1352
|
|
|
1312
|
-
#line
|
|
1353
|
+
#line 1353 "parser.c"
|
|
1313
1354
|
static const int JSON_string_start = 1;
|
|
1314
1355
|
static const int JSON_string_first_final = 8;
|
|
1315
1356
|
static const int JSON_string_error = 0;
|
|
@@ -1317,24 +1358,24 @@ static const int JSON_string_error = 0;
|
|
|
1317
1358
|
static const int JSON_string_en_main = 1;
|
|
1318
1359
|
|
|
1319
1360
|
|
|
1320
|
-
#line
|
|
1361
|
+
#line 470 "parser.rl"
|
|
1321
1362
|
|
|
1322
1363
|
|
|
1323
1364
|
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
|
1324
1365
|
{
|
|
1325
1366
|
int cs = EVIL;
|
|
1326
1367
|
|
|
1327
|
-
*result =
|
|
1368
|
+
*result = rb_str_buf_new(0);
|
|
1328
1369
|
|
|
1329
|
-
#line
|
|
1370
|
+
#line 1370 "parser.c"
|
|
1330
1371
|
{
|
|
1331
1372
|
cs = JSON_string_start;
|
|
1332
1373
|
}
|
|
1333
1374
|
|
|
1334
|
-
#line
|
|
1375
|
+
#line 478 "parser.rl"
|
|
1335
1376
|
json->memo = p;
|
|
1336
1377
|
|
|
1337
|
-
#line
|
|
1378
|
+
#line 1378 "parser.c"
|
|
1338
1379
|
{
|
|
1339
1380
|
if ( p == pe )
|
|
1340
1381
|
goto _test_eof;
|
|
@@ -1359,25 +1400,25 @@ case 2:
|
|
|
1359
1400
|
goto st0;
|
|
1360
1401
|
goto st2;
|
|
1361
1402
|
tr2:
|
|
1362
|
-
#line
|
|
1403
|
+
#line 456 "parser.rl"
|
|
1363
1404
|
{
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
#line
|
|
1405
|
+
*result = json_string_unescape(*result, json->memo + 1, p);
|
|
1406
|
+
if (NIL_P(*result)) {
|
|
1407
|
+
p--;
|
|
1408
|
+
{p++; cs = 8; goto _out;}
|
|
1409
|
+
} else {
|
|
1410
|
+
FORCE_UTF8(*result);
|
|
1411
|
+
{p = (( p + 1))-1;}
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
#line 467 "parser.rl"
|
|
1374
1415
|
{ p--; {p++; cs = 8; goto _out;} }
|
|
1375
1416
|
goto st8;
|
|
1376
1417
|
st8:
|
|
1377
1418
|
if ( ++p == pe )
|
|
1378
1419
|
goto _test_eof8;
|
|
1379
1420
|
case 8:
|
|
1380
|
-
#line
|
|
1421
|
+
#line 1421 "parser.c"
|
|
1381
1422
|
goto st0;
|
|
1382
1423
|
st3:
|
|
1383
1424
|
if ( ++p == pe )
|
|
@@ -1453,7 +1494,7 @@ case 7:
|
|
|
1453
1494
|
_out: {}
|
|
1454
1495
|
}
|
|
1455
1496
|
|
|
1456
|
-
#line
|
|
1497
|
+
#line 480 "parser.rl"
|
|
1457
1498
|
|
|
1458
1499
|
if (json->symbolize_names && json->parsing_name) {
|
|
1459
1500
|
*result = rb_str_intern(*result);
|
|
@@ -1467,7 +1508,7 @@ case 7:
|
|
|
1467
1508
|
|
|
1468
1509
|
|
|
1469
1510
|
|
|
1470
|
-
#line
|
|
1511
|
+
#line 1511 "parser.c"
|
|
1471
1512
|
static const int JSON_start = 1;
|
|
1472
1513
|
static const int JSON_first_final = 10;
|
|
1473
1514
|
static const int JSON_error = 0;
|
|
@@ -1475,7 +1516,7 @@ static const int JSON_error = 0;
|
|
|
1475
1516
|
static const int JSON_en_main = 1;
|
|
1476
1517
|
|
|
1477
1518
|
|
|
1478
|
-
#line
|
|
1519
|
+
#line 517 "parser.rl"
|
|
1479
1520
|
|
|
1480
1521
|
|
|
1481
1522
|
/*
|
|
@@ -1490,7 +1531,7 @@ static const int JSON_en_main = 1;
|
|
|
1490
1531
|
*
|
|
1491
1532
|
*/
|
|
1492
1533
|
|
|
1493
|
-
|
|
1534
|
+
static VALUE convert_encoding(VALUE source)
|
|
1494
1535
|
{
|
|
1495
1536
|
char *ptr = RSTRING_PTR(source);
|
|
1496
1537
|
long len = RSTRING_LEN(source);
|
|
@@ -1500,28 +1541,28 @@ inline static VALUE convert_encoding(VALUE source)
|
|
|
1500
1541
|
#ifdef HAVE_RUBY_ENCODING_H
|
|
1501
1542
|
{
|
|
1502
1543
|
VALUE encoding = rb_funcall(source, i_encoding, 0);
|
|
1503
|
-
if (encoding ==
|
|
1544
|
+
if (encoding == CEncoding_ASCII_8BIT) {
|
|
1504
1545
|
if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
|
|
1505
1546
|
source = rb_str_dup(source);
|
|
1506
|
-
rb_funcall(source, i_force_encoding, 1,
|
|
1507
|
-
source = rb_funcall(source, i_encode_bang, 1,
|
|
1547
|
+
rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_32BE);
|
|
1548
|
+
source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8);
|
|
1508
1549
|
} else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
|
|
1509
1550
|
source = rb_str_dup(source);
|
|
1510
|
-
rb_funcall(source, i_force_encoding, 1,
|
|
1511
|
-
source = rb_funcall(source, i_encode_bang, 1,
|
|
1551
|
+
rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_16BE);
|
|
1552
|
+
source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8);
|
|
1512
1553
|
} else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
|
|
1513
1554
|
source = rb_str_dup(source);
|
|
1514
|
-
rb_funcall(source, i_force_encoding, 1,
|
|
1515
|
-
source = rb_funcall(source, i_encode_bang, 1,
|
|
1555
|
+
rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_32LE);
|
|
1556
|
+
source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8);
|
|
1516
1557
|
} else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
|
|
1517
1558
|
source = rb_str_dup(source);
|
|
1518
|
-
rb_funcall(source, i_force_encoding, 1,
|
|
1519
|
-
source = rb_funcall(source, i_encode_bang, 1,
|
|
1559
|
+
rb_funcall(source, i_force_encoding, 1, CEncoding_UTF_16LE);
|
|
1560
|
+
source = rb_funcall(source, i_encode_bang, 1, CEncoding_UTF_8);
|
|
1520
1561
|
} else {
|
|
1521
|
-
|
|
1562
|
+
FORCE_UTF8(source);
|
|
1522
1563
|
}
|
|
1523
1564
|
} else {
|
|
1524
|
-
source = rb_funcall(source, i_encode, 1,
|
|
1565
|
+
source = rb_funcall(source, i_encode, 1, CEncoding_UTF_8);
|
|
1525
1566
|
}
|
|
1526
1567
|
}
|
|
1527
1568
|
#else
|
|
@@ -1569,7 +1610,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
1569
1610
|
char *ptr;
|
|
1570
1611
|
long len;
|
|
1571
1612
|
VALUE source, opts;
|
|
1572
|
-
|
|
1613
|
+
GET_PARSER;
|
|
1573
1614
|
rb_scan_args(argc, argv, "11", &source, &opts);
|
|
1574
1615
|
source = convert_encoding(StringValue(source));
|
|
1575
1616
|
ptr = RSTRING_PTR(source);
|
|
@@ -1654,19 +1695,19 @@ static VALUE cParser_parse(VALUE self)
|
|
|
1654
1695
|
char *p, *pe;
|
|
1655
1696
|
int cs = EVIL;
|
|
1656
1697
|
VALUE result = Qnil;
|
|
1657
|
-
|
|
1698
|
+
GET_PARSER;
|
|
1658
1699
|
|
|
1659
1700
|
|
|
1660
|
-
#line
|
|
1701
|
+
#line 1701 "parser.c"
|
|
1661
1702
|
{
|
|
1662
1703
|
cs = JSON_start;
|
|
1663
1704
|
}
|
|
1664
1705
|
|
|
1665
|
-
#line
|
|
1706
|
+
#line 698 "parser.rl"
|
|
1666
1707
|
p = json->source;
|
|
1667
1708
|
pe = p + json->len;
|
|
1668
1709
|
|
|
1669
|
-
#line
|
|
1710
|
+
#line 1710 "parser.c"
|
|
1670
1711
|
{
|
|
1671
1712
|
if ( p == pe )
|
|
1672
1713
|
goto _test_eof;
|
|
@@ -1722,7 +1763,7 @@ case 5:
|
|
|
1722
1763
|
goto st1;
|
|
1723
1764
|
goto st5;
|
|
1724
1765
|
tr3:
|
|
1725
|
-
#line
|
|
1766
|
+
#line 506 "parser.rl"
|
|
1726
1767
|
{
|
|
1727
1768
|
char *np;
|
|
1728
1769
|
json->current_nesting = 1;
|
|
@@ -1731,7 +1772,7 @@ tr3:
|
|
|
1731
1772
|
}
|
|
1732
1773
|
goto st10;
|
|
1733
1774
|
tr4:
|
|
1734
|
-
#line
|
|
1775
|
+
#line 499 "parser.rl"
|
|
1735
1776
|
{
|
|
1736
1777
|
char *np;
|
|
1737
1778
|
json->current_nesting = 1;
|
|
@@ -1743,7 +1784,7 @@ st10:
|
|
|
1743
1784
|
if ( ++p == pe )
|
|
1744
1785
|
goto _test_eof10;
|
|
1745
1786
|
case 10:
|
|
1746
|
-
#line
|
|
1787
|
+
#line 1787 "parser.c"
|
|
1747
1788
|
switch( (*p) ) {
|
|
1748
1789
|
case 13: goto st10;
|
|
1749
1790
|
case 32: goto st10;
|
|
@@ -1800,16 +1841,17 @@ case 9:
|
|
|
1800
1841
|
_out: {}
|
|
1801
1842
|
}
|
|
1802
1843
|
|
|
1803
|
-
#line
|
|
1844
|
+
#line 701 "parser.rl"
|
|
1804
1845
|
|
|
1805
1846
|
if (cs >= JSON_first_final && p == pe) {
|
|
1806
1847
|
return result;
|
|
1807
1848
|
} else {
|
|
1808
1849
|
rb_raise(eParserError, "%u: unexpected token at '%s'", __LINE__, p);
|
|
1850
|
+
return Qnil;
|
|
1809
1851
|
}
|
|
1810
1852
|
}
|
|
1811
1853
|
|
|
1812
|
-
|
|
1854
|
+
static JSON_Parser *JSON_allocate()
|
|
1813
1855
|
{
|
|
1814
1856
|
JSON_Parser *json = ALLOC(JSON_Parser);
|
|
1815
1857
|
MEMZERO(json, JSON_Parser, 1);
|
|
@@ -1843,7 +1885,7 @@ static VALUE cJSON_parser_s_allocate(VALUE klass)
|
|
|
1843
1885
|
*/
|
|
1844
1886
|
static VALUE cParser_source(VALUE self)
|
|
1845
1887
|
{
|
|
1846
|
-
|
|
1888
|
+
GET_PARSER;
|
|
1847
1889
|
return rb_str_dup(json->Vsource);
|
|
1848
1890
|
}
|
|
1849
1891
|
|
|
@@ -1877,12 +1919,12 @@ void Init_parser()
|
|
|
1877
1919
|
i_key_p = rb_intern("key?");
|
|
1878
1920
|
i_deep_const_get = rb_intern("deep_const_get");
|
|
1879
1921
|
#ifdef HAVE_RUBY_ENCODING_H
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1922
|
+
CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
|
|
1923
|
+
CEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be"));
|
|
1924
|
+
CEncoding_UTF_16LE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16le"));
|
|
1925
|
+
CEncoding_UTF_32BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-32be"));
|
|
1926
|
+
CEncoding_UTF_32LE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-32le"));
|
|
1927
|
+
CEncoding_ASCII_8BIT = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("ascii-8bit"));
|
|
1886
1928
|
i_encoding = rb_intern("encoding");
|
|
1887
1929
|
i_encode = rb_intern("encode");
|
|
1888
1930
|
i_encode_bang = rb_intern("encode!");
|