oj 3.12.3 → 3.13.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.3
4
+ version: 3.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-02 00:00:00.000000000 Z
11
+ date: 2021-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -86,6 +86,7 @@ extra_rdoc_files:
86
86
  - pages/JsonGem.md
87
87
  - pages/Modes.md
88
88
  - pages/Options.md
89
+ - pages/Parser.md
89
90
  - pages/Rails.md
90
91
  - pages/Security.md
91
92
  - pages/WAB.md
@@ -93,6 +94,8 @@ files:
93
94
  - LICENSE
94
95
  - README.md
95
96
  - ext/oj/buf.h
97
+ - ext/oj/cache.c
98
+ - ext/oj/cache.h
96
99
  - ext/oj/cache8.c
97
100
  - ext/oj/cache8.h
98
101
  - ext/oj/circarray.c
@@ -101,6 +104,7 @@ files:
101
104
  - ext/oj/code.h
102
105
  - ext/oj/compat.c
103
106
  - ext/oj/custom.c
107
+ - ext/oj/debug.c
104
108
  - ext/oj/dump.c
105
109
  - ext/oj/dump.h
106
110
  - ext/oj/dump_compat.c
@@ -112,9 +116,9 @@ files:
112
116
  - ext/oj/err.h
113
117
  - ext/oj/extconf.rb
114
118
  - ext/oj/fast.c
115
- - ext/oj/hash.c
116
- - ext/oj/hash.h
117
119
  - ext/oj/hash_test.c
120
+ - ext/oj/intern.c
121
+ - ext/oj/intern.h
118
122
  - ext/oj/mimic_json.c
119
123
  - ext/oj/object.c
120
124
  - ext/oj/odd.c
@@ -123,6 +127,8 @@ files:
123
127
  - ext/oj/oj.h
124
128
  - ext/oj/parse.c
125
129
  - ext/oj/parse.h
130
+ - ext/oj/parser.c
131
+ - ext/oj/parser.h
126
132
  - ext/oj/rails.c
127
133
  - ext/oj/rails.h
128
134
  - ext/oj/reader.c
@@ -132,6 +138,7 @@ files:
132
138
  - ext/oj/rxclass.c
133
139
  - ext/oj/rxclass.h
134
140
  - ext/oj/saj.c
141
+ - ext/oj/saj2.c
135
142
  - ext/oj/scp.c
136
143
  - ext/oj/sparse.c
137
144
  - ext/oj/stream_writer.c
@@ -139,10 +146,12 @@ files:
139
146
  - ext/oj/string_writer.c
140
147
  - ext/oj/trace.c
141
148
  - ext/oj/trace.h
149
+ - ext/oj/usual.c
142
150
  - ext/oj/util.c
143
151
  - ext/oj/util.h
144
152
  - ext/oj/val_stack.c
145
153
  - ext/oj/val_stack.h
154
+ - ext/oj/validate.c
146
155
  - ext/oj/wab.c
147
156
  - lib/oj.rb
148
157
  - lib/oj/active_support_helper.rb
@@ -162,6 +171,7 @@ files:
162
171
  - pages/JsonGem.md
163
172
  - pages/Modes.md
164
173
  - pages/Options.md
174
+ - pages/Parser.md
165
175
  - pages/Rails.md
166
176
  - pages/Security.md
167
177
  - pages/WAB.md
@@ -214,6 +224,7 @@ files:
214
224
  - test/perf_fast.rb
215
225
  - test/perf_file.rb
216
226
  - test/perf_object.rb
227
+ - test/perf_parser.rb
217
228
  - test/perf_saj.rb
218
229
  - test/perf_scp.rb
219
230
  - test/perf_simple.rb
@@ -245,6 +256,9 @@ files:
245
256
  - test/test_integer_range.rb
246
257
  - test/test_null.rb
247
258
  - test/test_object.rb
259
+ - test/test_parser.rb
260
+ - test/test_parser_saj.rb
261
+ - test/test_parser_usual.rb
248
262
  - test/test_rails.rb
249
263
  - test/test_saj.rb
250
264
  - test/test_scp.rb
@@ -339,6 +353,7 @@ test_files:
339
353
  - test/perf_fast.rb
340
354
  - test/perf_file.rb
341
355
  - test/perf_object.rb
356
+ - test/perf_parser.rb
342
357
  - test/perf_saj.rb
343
358
  - test/perf_scp.rb
344
359
  - test/perf_simple.rb
@@ -370,6 +385,9 @@ test_files:
370
385
  - test/test_integer_range.rb
371
386
  - test/test_null.rb
372
387
  - test/test_object.rb
388
+ - test/test_parser.rb
389
+ - test/test_parser_saj.rb
390
+ - test/test_parser_usual.rb
373
391
  - test/test_rails.rb
374
392
  - test/test_saj.rb
375
393
  - test/test_scp.rb
data/ext/oj/hash.c DELETED
@@ -1,168 +0,0 @@
1
- // Copyright (c) 2011 Peter Ohler. All rights reserved.
2
- // Licensed under the MIT License. See LICENSE file in the project root for license details.
3
-
4
- #include "hash.h"
5
-
6
- #include <stdint.h>
7
-
8
- #define HASH_SLOT_CNT ((uint32_t)8192)
9
- #define HASH_MASK (HASH_SLOT_CNT - 1)
10
-
11
- typedef struct _keyVal {
12
- struct _keyVal *next;
13
- const char * key;
14
- size_t len;
15
- VALUE val;
16
- } * KeyVal;
17
-
18
- struct _hash {
19
- struct _keyVal slots[HASH_SLOT_CNT];
20
- };
21
-
22
- struct _hash class_hash;
23
- struct _hash str_hash;
24
- struct _hash sym_hash;
25
- struct _hash intern_hash;
26
-
27
- // almost the Murmur hash algorithm
28
- #define M 0x5bd1e995
29
- #define C1 0xCC9E2D51
30
- #define C2 0x1B873593
31
- #define N 0xE6546B64
32
-
33
- static uint32_t hash_calc(const uint8_t *key, size_t len) {
34
- const uint8_t *end = key + len;
35
- const uint8_t *endless = key + (len / 4 * 4);
36
- uint32_t h = (uint32_t)len;
37
- uint32_t k;
38
-
39
- while (key < endless) {
40
- k = (uint32_t)*key++;
41
- k |= (uint32_t)*key++ << 8;
42
- k |= (uint32_t)*key++ << 16;
43
- k |= (uint32_t)*key++ << 24;
44
-
45
- k *= M;
46
- k ^= k >> 24;
47
- h *= M;
48
- h ^= k * M;
49
- }
50
- if (1 < end - key) {
51
- uint16_t k16 = (uint16_t)*key++;
52
-
53
- k16 |= (uint16_t)*key++ << 8;
54
- h ^= k16 << 8;
55
- }
56
- if (key < end) {
57
- h ^= *key;
58
- }
59
- h *= M;
60
- h ^= h >> 13;
61
- h *= M;
62
- h ^= h >> 15;
63
-
64
- return h;
65
- }
66
-
67
- void oj_hash_init() {
68
- memset(class_hash.slots, 0, sizeof(class_hash.slots));
69
- memset(str_hash.slots, 0, sizeof(str_hash.slots));
70
- memset(sym_hash.slots, 0, sizeof(sym_hash.slots));
71
- memset(intern_hash.slots, 0, sizeof(intern_hash.slots));
72
- }
73
-
74
- // if slotp is 0 then just lookup
75
- static VALUE hash_get(Hash hash, const char *key, size_t len, VALUE **slotp, VALUE def_value) {
76
- uint32_t h = hash_calc((const uint8_t *)key, len) & HASH_MASK;
77
- KeyVal bucket = hash->slots + h;
78
-
79
- if (0 != bucket->key) {
80
- KeyVal b;
81
-
82
- for (b = bucket; 0 != b; b = b->next) {
83
- if (len == b->len && 0 == strncmp(b->key, key, len)) {
84
- *slotp = &b->val;
85
- return b->val;
86
- }
87
- bucket = b;
88
- }
89
- }
90
- if (0 != slotp) {
91
- if (0 != bucket->key) {
92
- KeyVal b = ALLOC(struct _keyVal);
93
-
94
- b->next = 0;
95
- bucket->next = b;
96
- bucket = b;
97
- }
98
- bucket->key = oj_strndup(key, len);
99
- bucket->len = len;
100
- bucket->val = def_value;
101
- *slotp = &bucket->val;
102
- }
103
- return def_value;
104
- }
105
-
106
- void oj_hash_print() {
107
- uint32_t i;
108
- KeyVal b;
109
-
110
- for (i = 0; i < HASH_SLOT_CNT; i++) {
111
- printf("%4d:", i);
112
- for (b = class_hash.slots + i; 0 != b && 0 != b->key; b = b->next) {
113
- printf(" %s", b->key);
114
- }
115
- printf("\n");
116
- }
117
- }
118
-
119
- void oj_hash_sizes() {
120
- uint32_t i;
121
- KeyVal b;
122
- int max = 0;
123
- int min = 1000000;
124
-
125
- for (i = 0; i < HASH_SLOT_CNT; i++) {
126
- int cnt = 0;
127
-
128
- for (b = str_hash.slots + i; 0 != b && 0 != b->key; b = b->next) {
129
- cnt++;
130
- }
131
- // printf(" %4d\n", cnt);
132
- if (max < cnt) {
133
- max = cnt;
134
- }
135
- if (cnt < min) {
136
- min = cnt;
137
- }
138
- }
139
- printf("min: %d max: %d\n", min, max);
140
- }
141
-
142
- VALUE
143
- oj_class_hash_get(const char *key, size_t len, VALUE **slotp) {
144
- return hash_get(&class_hash, key, len, slotp, Qnil);
145
- }
146
-
147
- VALUE
148
- oj_str_hash_get(const char *key, size_t len, VALUE **slotp) {
149
- return hash_get(&str_hash, key, len, slotp, Qnil);
150
- }
151
-
152
- VALUE
153
- oj_sym_hash_get(const char *key, size_t len, VALUE **slotp) {
154
- return hash_get(&sym_hash, key, len, slotp, Qnil);
155
- }
156
-
157
- ID oj_attr_hash_get(const char *key, size_t len, ID **slotp) {
158
- return (ID)hash_get(&intern_hash, key, len, (VALUE **)slotp, 0);
159
- }
160
-
161
- char *oj_strndup(const char *s, size_t len) {
162
- char *d = ALLOC_N(char, len + 1);
163
-
164
- memcpy(d, s, len);
165
- d[len] = '\0';
166
-
167
- return d;
168
- }
data/ext/oj/hash.h DELETED
@@ -1,21 +0,0 @@
1
- // Copyright (c) 2011 Peter Ohler. All rights reserved.
2
- // Licensed under the MIT License. See LICENSE file in the project root for license details.
3
-
4
- #ifndef OJ_HASH_H
5
- #define OJ_HASH_H
6
-
7
- #include "ruby.h"
8
-
9
- typedef struct _hash *Hash;
10
-
11
- extern void oj_hash_init();
12
-
13
- extern VALUE oj_class_hash_get(const char *key, size_t len, VALUE **slotp);
14
- extern VALUE oj_str_hash_get(const char *key, size_t len, VALUE **slotp);
15
- extern VALUE oj_sym_hash_get(const char *key, size_t len, VALUE **slotp);
16
- extern ID oj_attr_hash_get(const char *key, size_t len, ID **slotp);
17
-
18
- extern void oj_hash_print();
19
- extern char *oj_strndup(const char *s, size_t len);
20
-
21
- #endif /* OJ_HASH_H */