oj 3.13.11 → 3.13.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -0
- data/README.md +2 -0
- data/ext/oj/buf.h +4 -0
- data/ext/oj/circarray.c +1 -1
- data/ext/oj/code.c +15 -22
- data/ext/oj/compat.c +10 -10
- data/ext/oj/custom.c +62 -108
- data/ext/oj/dump.c +85 -97
- data/ext/oj/dump.h +12 -8
- data/ext/oj/dump_compat.c +46 -88
- data/ext/oj/dump_leaf.c +14 -58
- data/ext/oj/dump_object.c +33 -156
- data/ext/oj/dump_strict.c +17 -29
- data/ext/oj/extconf.rb +5 -4
- data/ext/oj/fast.c +24 -22
- data/ext/oj/intern.c +15 -11
- data/ext/oj/intern.h +1 -1
- data/ext/oj/mimic_json.c +44 -32
- data/ext/oj/object.c +42 -41
- data/ext/oj/odd.c +83 -63
- data/ext/oj/odd.h +13 -13
- data/ext/oj/oj.c +57 -22
- data/ext/oj/oj.h +24 -3
- data/ext/oj/parse.c +114 -78
- data/ext/oj/parse.h +2 -0
- data/ext/oj/parser.c +77 -21
- data/ext/oj/parser.h +12 -0
- data/ext/oj/rails.c +41 -65
- data/ext/oj/rails.h +1 -1
- data/ext/oj/reader.c +2 -0
- data/ext/oj/saj.c +11 -23
- data/ext/oj/saj2.c +333 -85
- data/ext/oj/saj2.h +23 -0
- data/ext/oj/sparse.c +4 -0
- data/ext/oj/stream_writer.c +3 -1
- data/ext/oj/strict.c +13 -13
- data/ext/oj/string_writer.c +12 -5
- data/ext/oj/usual.c +82 -129
- data/ext/oj/usual.h +68 -0
- data/ext/oj/val_stack.c +1 -1
- data/ext/oj/validate.c +21 -26
- data/ext/oj/wab.c +21 -26
- data/lib/oj/saj.rb +20 -6
- data/lib/oj/state.rb +1 -1
- data/lib/oj/version.rb +1 -1
- data/pages/Compatibility.md +1 -1
- data/pages/Options.md +6 -0
- data/test/activesupport7/abstract_unit.rb +49 -0
- data/test/activesupport7/decoding_test.rb +125 -0
- data/test/activesupport7/encoding_test.rb +486 -0
- data/test/activesupport7/encoding_test_cases.rb +104 -0
- data/test/activesupport7/time_zone_test_helpers.rb +47 -0
- data/test/bar.rb +3 -8
- data/test/foo.rb +3 -3
- data/test/helper.rb +8 -2
- data/test/json_gem/json_generator_test.rb +5 -4
- data/test/json_gem/json_parser_test.rb +8 -1
- data/test/json_gem/test_helper.rb +7 -3
- data/test/perf_dump.rb +50 -0
- data/test/test_compat.rb +25 -0
- data/test/test_custom.rb +13 -2
- data/test/test_file.rb +23 -7
- data/test/test_gc.rb +11 -0
- data/test/test_object.rb +8 -10
- data/test/test_parser.rb +3 -19
- data/test/test_parser_debug.rb +27 -0
- data/test/test_parser_saj.rb +92 -2
- data/test/test_scp.rb +2 -4
- data/test/test_strict.rb +2 -0
- data/test/test_various.rb +8 -3
- data/test/test_wab.rb +2 -0
- data/test/tests.rb +9 -0
- data/test/tests_mimic.rb +9 -0
- data/test/tests_mimic_addition.rb +9 -0
- metadata +13 -116
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d2f8a01b7a59da7cd25ed3551065dddd9e31e5184989804d172c2e39cc769d6
|
4
|
+
data.tar.gz: 7211a96856ec44173fa9dcc7245e3cb2f6b7c2e22a746ef35f168126873f4c88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee3ad5cac6cac48bcf7fdf682e69770dfee08b502735cc75b84ae1635196fdcdaf2fde021e32e6d897bdc6935e111882ddc48fa5a274fe0d98ad45c2fdf68917
|
7
|
+
data.tar.gz: 3e05212fa84a2bf05954ec870ac27da7c845335b411507aa0bf5e45497403cccf4c40990f0ee8cee6d21f19163f33116bb240836795482737eaa744bc5ff6d94
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,55 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 3.13.23 - 2022-11-06
|
4
|
+
|
5
|
+
- Fixed issue with Oj::Parser extension regarding GC timeing.
|
6
|
+
|
7
|
+
## 3.13.22 - 2022-11-01
|
8
|
+
|
9
|
+
- Reorganized Oj::Parser code to allow for parser extensions in C.
|
10
|
+
|
11
|
+
## 3.13.21 - 2022-08-19
|
12
|
+
|
13
|
+
- Bug parsing big numbers fixed in the SAJ parser.
|
14
|
+
|
15
|
+
## 3.13.20 - 2022-08-07
|
16
|
+
|
17
|
+
- SSE4 made optional with a `--with-sse42` flag to the compile.
|
18
|
+
|
19
|
+
## 3.13.19 - 2022-07-29
|
20
|
+
|
21
|
+
- TruffleRuby issues resolved.
|
22
|
+
|
23
|
+
## 3.13.18 - 2022-07-25
|
24
|
+
|
25
|
+
- Fixed SSE detection at run time.
|
26
|
+
|
27
|
+
## 3.13.17 - 2022-07-15
|
28
|
+
|
29
|
+
- Fixed Oj::Parser to detect unterminated arrays and objects.
|
30
|
+
|
31
|
+
## 3.13.16 - 2022-07-06
|
32
|
+
|
33
|
+
- Added line and column as optional arguments to the Oj::Parser.saj parser.
|
34
|
+
|
35
|
+
## 3.13.15 - 2022-07-03
|
36
|
+
|
37
|
+
- Fixed issue dumping NaN value in object mode.
|
38
|
+
|
39
|
+
## 3.13.14 - 2022-06-03
|
40
|
+
|
41
|
+
- Double fclose() due to bad merger fixed by tonobo.
|
42
|
+
|
43
|
+
## 3.13.13 - 2022-05-20
|
44
|
+
|
45
|
+
- Fixed flooding stdout with debug output when dumping.
|
46
|
+
|
47
|
+
## 3.13.12 - 2022-05-20
|
48
|
+
|
49
|
+
- Fixed crash on no arguments to pretty_generate. Now raises an exception.
|
50
|
+
- Register all classes and globals.
|
51
|
+
- Fixed memory issue with dumping.
|
52
|
+
|
3
53
|
## 3.13.11 - 2022-01-05
|
4
54
|
|
5
55
|
- Fixed write blocking failures on writes to a slow stream with larger writes.
|
data/README.md
CHANGED
@@ -109,6 +109,8 @@ Follow [@peterohler on Twitter](http://twitter.com/peterohler) for announcements
|
|
109
109
|
|
110
110
|
- *Agoo-C, a high performance C web server supporting GraphQL on GitHub*: https://github.com/ohler55/agoo-c
|
111
111
|
|
112
|
+
- *oj-introspect, an example of creating an Oj parser extension in C*: https://github.com/meinac/oj-introspect
|
113
|
+
|
112
114
|
#### Contributing
|
113
115
|
|
114
116
|
+ Provide a Pull Request off the `develop` branch.
|
data/ext/oj/buf.h
CHANGED
@@ -39,6 +39,10 @@ inline static const char *buf_str(Buf buf) {
|
|
39
39
|
}
|
40
40
|
|
41
41
|
inline static void buf_append_string(Buf buf, const char *s, size_t slen) {
|
42
|
+
if (0 == slen) {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
|
42
46
|
if (buf->end <= buf->tail + slen) {
|
43
47
|
size_t len = buf->end - buf->head;
|
44
48
|
size_t toff = buf->tail - buf->head;
|
data/ext/oj/circarray.c
CHANGED
data/ext/oj/code.c
CHANGED
@@ -140,21 +140,17 @@ void oj_code_attrs(VALUE obj, Attr attrs, int depth, Out out, bool with_class) {
|
|
140
140
|
if (with_class) {
|
141
141
|
fill_indent(out, d2);
|
142
142
|
*out->cur++ = '"';
|
143
|
-
|
144
|
-
out->cur += out->opts->create_id_len;
|
143
|
+
APPEND_CHARS(out->cur, out->opts->create_id, out->opts->create_id_len);
|
145
144
|
*out->cur++ = '"';
|
146
145
|
if (0 < out->opts->dump_opts.before_size) {
|
147
|
-
|
148
|
-
out->cur += out->opts->dump_opts.before_size;
|
146
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.before_sep, out->opts->dump_opts.before_size);
|
149
147
|
}
|
150
148
|
*out->cur++ = ':';
|
151
149
|
if (0 < out->opts->dump_opts.after_size) {
|
152
|
-
|
153
|
-
out->cur += out->opts->dump_opts.after_size;
|
150
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.after_sep, out->opts->dump_opts.after_size);
|
154
151
|
}
|
155
152
|
*out->cur++ = '"';
|
156
|
-
|
157
|
-
out->cur += len;
|
153
|
+
APPEND_CHARS(out->cur, classname, len);
|
158
154
|
*out->cur++ = '"';
|
159
155
|
no_comma = false;
|
160
156
|
}
|
@@ -168,17 +164,14 @@ void oj_code_attrs(VALUE obj, Attr attrs, int depth, Out out, bool with_class) {
|
|
168
164
|
}
|
169
165
|
fill_indent(out, d2);
|
170
166
|
*out->cur++ = '"';
|
171
|
-
|
172
|
-
out->cur += attrs->len;
|
167
|
+
APPEND_CHARS(out->cur, attrs->name, attrs->len);
|
173
168
|
*out->cur++ = '"';
|
174
169
|
if (0 < out->opts->dump_opts.before_size) {
|
175
|
-
|
176
|
-
out->cur += out->opts->dump_opts.before_size;
|
170
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.before_sep, out->opts->dump_opts.before_size);
|
177
171
|
}
|
178
172
|
*out->cur++ = ':';
|
179
173
|
if (0 < out->opts->dump_opts.after_size) {
|
180
|
-
|
181
|
-
out->cur += out->opts->dump_opts.after_size;
|
174
|
+
APPEND_CHARS(out->cur, out->opts->dump_opts.after_sep, out->opts->dump_opts.after_size);
|
182
175
|
}
|
183
176
|
if (Qundef == attrs->value) {
|
184
177
|
if (Qundef != attrs->time) {
|
@@ -190,10 +183,11 @@ void oj_code_attrs(VALUE obj, Attr attrs, int depth, Out out, bool with_class) {
|
|
190
183
|
default: oj_dump_time(attrs->time, out, false); break;
|
191
184
|
}
|
192
185
|
} else {
|
193
|
-
char
|
194
|
-
char
|
195
|
-
int
|
196
|
-
long
|
186
|
+
char buf[32];
|
187
|
+
char *b = buf + sizeof(buf) - 1;
|
188
|
+
int neg = 0;
|
189
|
+
long num = attrs->num;
|
190
|
+
size_t cnt = 0;
|
197
191
|
|
198
192
|
if (0 > num) {
|
199
193
|
neg = 1;
|
@@ -212,10 +206,9 @@ void oj_code_attrs(VALUE obj, Attr attrs, int depth, Out out, bool with_class) {
|
|
212
206
|
} else {
|
213
207
|
*b = '0';
|
214
208
|
}
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
}
|
209
|
+
cnt = sizeof(buf) - (b - buf) - 1;
|
210
|
+
assure_size(out, cnt);
|
211
|
+
APPEND_CHARS(out->cur, b, cnt);
|
219
212
|
}
|
220
213
|
} else {
|
221
214
|
oj_dump_compat_val(attrs->value, d3, out, true);
|
data/ext/oj/compat.c
CHANGED
@@ -54,7 +54,7 @@ static void hash_set_cstr(ParseInfo pi, Val kval, const char *str, size_t len, c
|
|
54
54
|
} else {
|
55
55
|
rb_hash_aset(parent->val, rkey, rstr);
|
56
56
|
}
|
57
|
-
if (Yes == pi->options.trace) {
|
57
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
58
58
|
oj_trace_parse_call("set_string", pi, __FILE__, __LINE__, rstr);
|
59
59
|
}
|
60
60
|
}
|
@@ -68,7 +68,7 @@ static VALUE start_hash(ParseInfo pi) {
|
|
68
68
|
} else {
|
69
69
|
h = rb_hash_new();
|
70
70
|
}
|
71
|
-
if (Yes == pi->options.trace) {
|
71
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
72
72
|
oj_trace_parse_in("start_hash", pi, __FILE__, __LINE__);
|
73
73
|
}
|
74
74
|
return h;
|
@@ -93,7 +93,7 @@ static void end_hash(struct _parseInfo *pi) {
|
|
93
93
|
parent->classname = 0;
|
94
94
|
}
|
95
95
|
}
|
96
|
-
if (Yes == pi->options.trace) {
|
96
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
97
97
|
oj_trace_parse_hash_end(pi, __FILE__, __LINE__);
|
98
98
|
}
|
99
99
|
}
|
@@ -110,14 +110,14 @@ static void add_cstr(ParseInfo pi, const char *str, size_t len, const char *orig
|
|
110
110
|
}
|
111
111
|
}
|
112
112
|
pi->stack.head->val = rstr;
|
113
|
-
if (Yes == pi->options.trace) {
|
113
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
114
114
|
oj_trace_parse_call("add_string", pi, __FILE__, __LINE__, rstr);
|
115
115
|
}
|
116
116
|
}
|
117
117
|
|
118
118
|
static void add_num(ParseInfo pi, NumInfo ni) {
|
119
119
|
pi->stack.head->val = oj_num_as_value(ni);
|
120
|
-
if (Yes == pi->options.trace) {
|
120
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
121
121
|
oj_trace_parse_call("add_number", pi, __FILE__, __LINE__, pi->stack.head->val);
|
122
122
|
}
|
123
123
|
}
|
@@ -138,7 +138,7 @@ static void hash_set_num(struct _parseInfo *pi, Val parent, NumInfo ni) {
|
|
138
138
|
} else {
|
139
139
|
rb_hash_aset(stack_peek(&pi->stack)->val, oj_calc_hash_key(pi, parent), rval);
|
140
140
|
}
|
141
|
-
if (Yes == pi->options.trace) {
|
141
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
142
142
|
oj_trace_parse_call("set_number", pi, __FILE__, __LINE__, rval);
|
143
143
|
}
|
144
144
|
}
|
@@ -157,7 +157,7 @@ static void hash_set_value(ParseInfo pi, Val parent, VALUE value) {
|
|
157
157
|
} else {
|
158
158
|
rb_hash_aset(stack_peek(&pi->stack)->val, oj_calc_hash_key(pi, parent), value);
|
159
159
|
}
|
160
|
-
if (Yes == pi->options.trace) {
|
160
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
161
161
|
oj_trace_parse_call("set_value", pi, __FILE__, __LINE__, value);
|
162
162
|
}
|
163
163
|
}
|
@@ -166,7 +166,7 @@ static VALUE start_array(ParseInfo pi) {
|
|
166
166
|
if (Qnil != pi->options.array_class) {
|
167
167
|
return rb_class_new_instance(0, NULL, pi->options.array_class);
|
168
168
|
}
|
169
|
-
if (Yes == pi->options.trace) {
|
169
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
170
170
|
oj_trace_parse_in("start_array", pi, __FILE__, __LINE__);
|
171
171
|
}
|
172
172
|
return rb_ary_new();
|
@@ -184,7 +184,7 @@ static void array_append_num(ParseInfo pi, NumInfo ni) {
|
|
184
184
|
} else {
|
185
185
|
rb_ary_push(parent->val, rval);
|
186
186
|
}
|
187
|
-
if (Yes == pi->options.trace) {
|
187
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
188
188
|
oj_trace_parse_call("append_number", pi, __FILE__, __LINE__, rval);
|
189
189
|
}
|
190
190
|
}
|
@@ -201,7 +201,7 @@ static void array_append_cstr(ParseInfo pi, const char *str, size_t len, const c
|
|
201
201
|
}
|
202
202
|
}
|
203
203
|
rb_ary_push(stack_peek(&pi->stack)->val, rstr);
|
204
|
-
if (Yes == pi->options.trace) {
|
204
|
+
if (RB_UNLIKELY(Yes == pi->options.trace)) {
|
205
205
|
oj_trace_parse_call("append_string", pi, __FILE__, __LINE__, rstr);
|
206
206
|
}
|
207
207
|
}
|