oj 3.11.0 → 3.16.5

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.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1421 -0
  3. data/README.md +20 -5
  4. data/RELEASE_NOTES.md +61 -0
  5. data/ext/oj/buf.h +48 -38
  6. data/ext/oj/cache.c +329 -0
  7. data/ext/oj/cache.h +22 -0
  8. data/ext/oj/cache8.c +60 -62
  9. data/ext/oj/cache8.h +8 -7
  10. data/ext/oj/circarray.c +35 -35
  11. data/ext/oj/circarray.h +11 -9
  12. data/ext/oj/code.c +156 -174
  13. data/ext/oj/code.h +19 -18
  14. data/ext/oj/compat.c +140 -197
  15. data/ext/oj/custom.c +737 -879
  16. data/ext/oj/debug.c +126 -0
  17. data/ext/oj/dump.c +830 -835
  18. data/ext/oj/dump.h +65 -53
  19. data/ext/oj/dump_compat.c +566 -642
  20. data/ext/oj/dump_leaf.c +95 -182
  21. data/ext/oj/dump_object.c +518 -659
  22. data/ext/oj/dump_strict.c +301 -334
  23. data/ext/oj/encode.h +3 -4
  24. data/ext/oj/encoder.c +43 -0
  25. data/ext/oj/err.c +27 -24
  26. data/ext/oj/err.h +38 -13
  27. data/ext/oj/extconf.rb +23 -7
  28. data/ext/oj/fast.c +1043 -1073
  29. data/ext/oj/intern.c +313 -0
  30. data/ext/oj/intern.h +22 -0
  31. data/ext/oj/mem.c +318 -0
  32. data/ext/oj/mem.h +53 -0
  33. data/ext/oj/mimic_json.c +449 -423
  34. data/ext/oj/object.c +530 -576
  35. data/ext/oj/odd.c +155 -138
  36. data/ext/oj/odd.h +24 -22
  37. data/ext/oj/oj.c +1331 -993
  38. data/ext/oj/oj.h +306 -292
  39. data/ext/oj/parse.c +934 -938
  40. data/ext/oj/parse.h +73 -70
  41. data/ext/oj/parser.c +1600 -0
  42. data/ext/oj/parser.h +101 -0
  43. data/ext/oj/rails.c +795 -845
  44. data/ext/oj/rails.h +7 -7
  45. data/ext/oj/reader.c +132 -140
  46. data/ext/oj/reader.h +67 -78
  47. data/ext/oj/resolve.c +40 -59
  48. data/ext/oj/resolve.h +3 -2
  49. data/ext/oj/rxclass.c +67 -67
  50. data/ext/oj/rxclass.h +11 -9
  51. data/ext/oj/saj.c +441 -480
  52. data/ext/oj/saj2.c +584 -0
  53. data/ext/oj/saj2.h +23 -0
  54. data/ext/oj/scp.c +78 -111
  55. data/ext/oj/sparse.c +726 -730
  56. data/ext/oj/stream_writer.c +146 -165
  57. data/ext/oj/strict.c +103 -123
  58. data/ext/oj/string_writer.c +241 -253
  59. data/ext/oj/trace.c +29 -33
  60. data/ext/oj/trace.h +41 -11
  61. data/ext/oj/usual.c +1218 -0
  62. data/ext/oj/usual.h +69 -0
  63. data/ext/oj/util.c +103 -103
  64. data/ext/oj/util.h +3 -2
  65. data/ext/oj/val_stack.c +60 -49
  66. data/ext/oj/val_stack.h +79 -85
  67. data/ext/oj/validate.c +46 -0
  68. data/ext/oj/wab.c +307 -350
  69. data/lib/oj/active_support_helper.rb +1 -3
  70. data/lib/oj/bag.rb +8 -1
  71. data/lib/oj/easy_hash.rb +9 -9
  72. data/lib/oj/error.rb +1 -2
  73. data/lib/oj/json.rb +162 -150
  74. data/lib/oj/mimic.rb +9 -19
  75. data/lib/oj/saj.rb +20 -6
  76. data/lib/oj/schandler.rb +5 -4
  77. data/lib/oj/state.rb +12 -8
  78. data/lib/oj/version.rb +1 -2
  79. data/lib/oj.rb +2 -0
  80. data/pages/Compatibility.md +1 -1
  81. data/pages/InstallOptions.md +20 -0
  82. data/pages/JsonGem.md +15 -0
  83. data/pages/Modes.md +8 -3
  84. data/pages/Options.md +43 -5
  85. data/pages/Parser.md +309 -0
  86. data/pages/Rails.md +14 -2
  87. data/test/_test_active.rb +8 -9
  88. data/test/_test_active_mimic.rb +7 -8
  89. data/test/_test_mimic_rails.rb +17 -20
  90. data/test/activerecord/result_test.rb +12 -8
  91. data/test/activesupport6/encoding_test.rb +63 -28
  92. data/test/{activesupport5 → activesupport7}/abstract_unit.rb +16 -12
  93. data/test/{activesupport5 → activesupport7}/decoding_test.rb +2 -10
  94. data/test/{activesupport5 → activesupport7}/encoding_test.rb +86 -50
  95. data/test/{activesupport5 → activesupport7}/encoding_test_cases.rb +6 -0
  96. data/test/{activesupport5 → activesupport7}/time_zone_test_helpers.rb +8 -0
  97. data/test/files.rb +15 -15
  98. data/test/foo.rb +17 -43
  99. data/test/helper.rb +16 -3
  100. data/test/isolated/shared.rb +3 -2
  101. data/test/json_gem/json_addition_test.rb +2 -2
  102. data/test/json_gem/json_common_interface_test.rb +8 -6
  103. data/test/json_gem/json_encoding_test.rb +0 -0
  104. data/test/json_gem/json_ext_parser_test.rb +1 -0
  105. data/test/json_gem/json_fixtures_test.rb +3 -2
  106. data/test/json_gem/json_generator_test.rb +71 -41
  107. data/test/json_gem/json_generic_object_test.rb +11 -11
  108. data/test/json_gem/json_parser_test.rb +54 -47
  109. data/test/json_gem/json_string_matching_test.rb +9 -9
  110. data/test/json_gem/test_helper.rb +12 -0
  111. data/test/mem.rb +34 -0
  112. data/test/perf.rb +22 -27
  113. data/test/perf_compat.rb +31 -33
  114. data/test/perf_dump.rb +50 -0
  115. data/test/perf_fast.rb +80 -82
  116. data/test/perf_file.rb +27 -29
  117. data/test/perf_object.rb +65 -69
  118. data/test/perf_once.rb +59 -0
  119. data/test/perf_parser.rb +183 -0
  120. data/test/perf_saj.rb +46 -54
  121. data/test/perf_scp.rb +58 -69
  122. data/test/perf_simple.rb +41 -39
  123. data/test/perf_strict.rb +74 -82
  124. data/test/perf_wab.rb +67 -69
  125. data/test/prec.rb +5 -5
  126. data/test/sample/change.rb +0 -1
  127. data/test/sample/dir.rb +0 -1
  128. data/test/sample/doc.rb +0 -1
  129. data/test/sample/file.rb +0 -1
  130. data/test/sample/group.rb +0 -1
  131. data/test/sample/hasprops.rb +0 -1
  132. data/test/sample/layer.rb +0 -1
  133. data/test/sample/rect.rb +0 -1
  134. data/test/sample/shape.rb +0 -1
  135. data/test/sample/text.rb +0 -1
  136. data/test/sample.rb +16 -16
  137. data/test/sample_json.rb +8 -8
  138. data/test/test_compat.rb +97 -45
  139. data/test/test_custom.rb +73 -51
  140. data/test/test_debian.rb +7 -10
  141. data/test/test_fast.rb +135 -79
  142. data/test/test_file.rb +41 -30
  143. data/test/test_gc.rb +16 -5
  144. data/test/test_generate.rb +21 -0
  145. data/test/test_hash.rb +15 -5
  146. data/test/test_integer_range.rb +9 -9
  147. data/test/test_null.rb +20 -20
  148. data/test/test_object.rb +99 -96
  149. data/test/test_parser.rb +11 -0
  150. data/test/test_parser_debug.rb +27 -0
  151. data/test/test_parser_saj.rb +337 -0
  152. data/test/test_parser_usual.rb +251 -0
  153. data/test/test_rails.rb +2 -2
  154. data/test/test_saj.rb +10 -8
  155. data/test/test_scp.rb +38 -40
  156. data/test/test_strict.rb +40 -32
  157. data/test/test_various.rb +165 -84
  158. data/test/test_wab.rb +48 -44
  159. data/test/test_writer.rb +47 -47
  160. data/test/tests.rb +13 -5
  161. data/test/tests_mimic.rb +12 -3
  162. data/test/tests_mimic_addition.rb +12 -3
  163. metadata +75 -127
  164. data/ext/oj/hash.c +0 -135
  165. data/ext/oj/hash.h +0 -18
  166. data/ext/oj/hash_test.c +0 -484
  167. data/test/activesupport4/decoding_test.rb +0 -108
  168. data/test/activesupport4/encoding_test.rb +0 -531
  169. data/test/activesupport4/test_helper.rb +0 -41
  170. data/test/activesupport5/test_helper.rb +0 -72
  171. data/test/bar.rb +0 -35
  172. data/test/baz.rb +0 -16
  173. data/test/zoo.rb +0 -13
metadata CHANGED
@@ -1,35 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 3.16.5
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-01-12 00:00:00.000000000 Z
11
+ date: 2024-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake-compiler
14
+ name: bigdecimal
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.9'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '2.0'
23
- type: :development
19
+ version: '3.0'
20
+ type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '0.9'
30
- - - "<"
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ostruct
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
- version: '2.0'
33
+ version: '0.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
33
41
  - !ruby/object:Gem::Dependency
34
42
  name: minitest
35
43
  requirement: !ruby/object:Gem::Requirement
@@ -45,33 +53,39 @@ dependencies:
45
53
  - !ruby/object:Gem::Version
46
54
  version: '5'
47
55
  - !ruby/object:Gem::Dependency
48
- name: test-unit
56
+ name: rake-compiler
49
57
  requirement: !ruby/object:Gem::Requirement
50
58
  requirements:
51
- - - "~>"
59
+ - - ">="
52
60
  - !ruby/object:Gem::Version
53
- version: '3.0'
61
+ version: '0.9'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '2.0'
54
65
  type: :development
55
66
  prerelease: false
56
67
  version_requirements: !ruby/object:Gem::Requirement
57
68
  requirements:
58
- - - "~>"
69
+ - - ">="
59
70
  - !ruby/object:Gem::Version
60
- version: '3.0'
71
+ version: '0.9'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.0'
61
75
  - !ruby/object:Gem::Dependency
62
- name: wwtd
76
+ name: test-unit
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
79
  - - "~>"
66
80
  - !ruby/object:Gem::Version
67
- version: '0'
81
+ version: '3.0'
68
82
  type: :development
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
86
  - - "~>"
73
87
  - !ruby/object:Gem::Version
74
- version: '0'
88
+ version: '3.0'
75
89
  description: The fastest JSON parser and object serializer.
76
90
  email: peter@ohler.com
77
91
  executables: []
@@ -79,20 +93,29 @@ extensions:
79
93
  - ext/oj/extconf.rb
80
94
  extra_rdoc_files:
81
95
  - README.md
96
+ - LICENSE
97
+ - CHANGELOG.md
98
+ - RELEASE_NOTES.md
82
99
  - pages/Advanced.md
83
100
  - pages/Compatibility.md
84
101
  - pages/Custom.md
85
102
  - pages/Encoding.md
103
+ - pages/InstallOptions.md
86
104
  - pages/JsonGem.md
87
105
  - pages/Modes.md
88
106
  - pages/Options.md
107
+ - pages/Parser.md
89
108
  - pages/Rails.md
90
109
  - pages/Security.md
91
110
  - pages/WAB.md
92
111
  files:
112
+ - CHANGELOG.md
93
113
  - LICENSE
94
114
  - README.md
115
+ - RELEASE_NOTES.md
95
116
  - ext/oj/buf.h
117
+ - ext/oj/cache.c
118
+ - ext/oj/cache.h
96
119
  - ext/oj/cache8.c
97
120
  - ext/oj/cache8.h
98
121
  - ext/oj/circarray.c
@@ -101,6 +124,7 @@ files:
101
124
  - ext/oj/code.h
102
125
  - ext/oj/compat.c
103
126
  - ext/oj/custom.c
127
+ - ext/oj/debug.c
104
128
  - ext/oj/dump.c
105
129
  - ext/oj/dump.h
106
130
  - ext/oj/dump_compat.c
@@ -108,13 +132,15 @@ files:
108
132
  - ext/oj/dump_object.c
109
133
  - ext/oj/dump_strict.c
110
134
  - ext/oj/encode.h
135
+ - ext/oj/encoder.c
111
136
  - ext/oj/err.c
112
137
  - ext/oj/err.h
113
138
  - ext/oj/extconf.rb
114
139
  - ext/oj/fast.c
115
- - ext/oj/hash.c
116
- - ext/oj/hash.h
117
- - ext/oj/hash_test.c
140
+ - ext/oj/intern.c
141
+ - ext/oj/intern.h
142
+ - ext/oj/mem.c
143
+ - ext/oj/mem.h
118
144
  - ext/oj/mimic_json.c
119
145
  - ext/oj/object.c
120
146
  - ext/oj/odd.c
@@ -123,6 +149,8 @@ files:
123
149
  - ext/oj/oj.h
124
150
  - ext/oj/parse.c
125
151
  - ext/oj/parse.h
152
+ - ext/oj/parser.c
153
+ - ext/oj/parser.h
126
154
  - ext/oj/rails.c
127
155
  - ext/oj/rails.h
128
156
  - ext/oj/reader.c
@@ -132,6 +160,8 @@ files:
132
160
  - ext/oj/rxclass.c
133
161
  - ext/oj/rxclass.h
134
162
  - ext/oj/saj.c
163
+ - ext/oj/saj2.c
164
+ - ext/oj/saj2.h
135
165
  - ext/oj/scp.c
136
166
  - ext/oj/sparse.c
137
167
  - ext/oj/stream_writer.c
@@ -139,10 +169,13 @@ files:
139
169
  - ext/oj/string_writer.c
140
170
  - ext/oj/trace.c
141
171
  - ext/oj/trace.h
172
+ - ext/oj/usual.c
173
+ - ext/oj/usual.h
142
174
  - ext/oj/util.c
143
175
  - ext/oj/util.h
144
176
  - ext/oj/val_stack.c
145
177
  - ext/oj/val_stack.h
178
+ - ext/oj/validate.c
146
179
  - ext/oj/wab.c
147
180
  - lib/oj.rb
148
181
  - lib/oj/active_support_helper.rb
@@ -159,9 +192,11 @@ files:
159
192
  - pages/Compatibility.md
160
193
  - pages/Custom.md
161
194
  - pages/Encoding.md
195
+ - pages/InstallOptions.md
162
196
  - pages/JsonGem.md
163
197
  - pages/Modes.md
164
198
  - pages/Options.md
199
+ - pages/Parser.md
165
200
  - pages/Rails.md
166
201
  - pages/Security.md
167
202
  - pages/WAB.md
@@ -169,15 +204,6 @@ files:
169
204
  - test/_test_active_mimic.rb
170
205
  - test/_test_mimic_rails.rb
171
206
  - test/activerecord/result_test.rb
172
- - test/activesupport4/decoding_test.rb
173
- - test/activesupport4/encoding_test.rb
174
- - test/activesupport4/test_helper.rb
175
- - test/activesupport5/abstract_unit.rb
176
- - test/activesupport5/decoding_test.rb
177
- - test/activesupport5/encoding_test.rb
178
- - test/activesupport5/encoding_test_cases.rb
179
- - test/activesupport5/test_helper.rb
180
- - test/activesupport5/time_zone_test_helpers.rb
181
207
  - test/activesupport6/abstract_unit.rb
182
208
  - test/activesupport6/decoding_test.rb
183
209
  - test/activesupport6/encoding_test.rb
@@ -185,8 +211,11 @@ files:
185
211
  - test/activesupport6/test_common.rb
186
212
  - test/activesupport6/test_helper.rb
187
213
  - test/activesupport6/time_zone_test_helpers.rb
188
- - test/bar.rb
189
- - test/baz.rb
214
+ - test/activesupport7/abstract_unit.rb
215
+ - test/activesupport7/decoding_test.rb
216
+ - test/activesupport7/encoding_test.rb
217
+ - test/activesupport7/encoding_test_cases.rb
218
+ - test/activesupport7/time_zone_test_helpers.rb
190
219
  - test/files.rb
191
220
  - test/foo.rb
192
221
  - test/helper.rb
@@ -209,11 +238,15 @@ files:
209
238
  - test/json_gem/json_parser_test.rb
210
239
  - test/json_gem/json_string_matching_test.rb
211
240
  - test/json_gem/test_helper.rb
241
+ - test/mem.rb
212
242
  - test/perf.rb
213
243
  - test/perf_compat.rb
244
+ - test/perf_dump.rb
214
245
  - test/perf_fast.rb
215
246
  - test/perf_file.rb
216
247
  - test/perf_object.rb
248
+ - test/perf_once.rb
249
+ - test/perf_parser.rb
217
250
  - test/perf_saj.rb
218
251
  - test/perf_scp.rb
219
252
  - test/perf_simple.rb
@@ -240,10 +273,15 @@ files:
240
273
  - test/test_fast.rb
241
274
  - test/test_file.rb
242
275
  - test/test_gc.rb
276
+ - test/test_generate.rb
243
277
  - test/test_hash.rb
244
278
  - test/test_integer_range.rb
245
279
  - test/test_null.rb
246
280
  - test/test_object.rb
281
+ - test/test_parser.rb
282
+ - test/test_parser_debug.rb
283
+ - test/test_parser_saj.rb
284
+ - test/test_parser_usual.rb
247
285
  - test/test_rails.rb
248
286
  - test/test_saj.rb
249
287
  - test/test_scp.rb
@@ -254,7 +292,6 @@ files:
254
292
  - test/tests.rb
255
293
  - test/tests_mimic.rb
256
294
  - test/tests_mimic_addition.rb
257
- - test/zoo.rb
258
295
  homepage: http://www.ohler.com/oj
259
296
  licenses:
260
297
  - MIT
@@ -265,6 +302,7 @@ metadata:
265
302
  homepage_uri: http://www.ohler.com/oj/
266
303
  source_code_uri: https://github.com/ohler55/oj
267
304
  wiki_uri: https://github.com/ohler55/oj/wiki
305
+ rubygems_mfa_required: 'true'
268
306
  post_install_message:
269
307
  rdoc_options:
270
308
  - "--title"
@@ -277,105 +315,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
277
315
  requirements:
278
316
  - - ">="
279
317
  - !ruby/object:Gem::Version
280
- version: '2.4'
318
+ version: '2.7'
281
319
  required_rubygems_version: !ruby/object:Gem::Requirement
282
320
  requirements:
283
321
  - - ">="
284
322
  - !ruby/object:Gem::Version
285
323
  version: '0'
286
324
  requirements: []
287
- rubygems_version: 3.2.3
325
+ rubygems_version: 3.4.10
288
326
  signing_key:
289
327
  specification_version: 4
290
328
  summary: A fast JSON parser and serializer.
291
- test_files:
292
- - test/_test_active.rb
293
- - test/_test_active_mimic.rb
294
- - test/_test_mimic_rails.rb
295
- - test/activerecord/result_test.rb
296
- - test/activesupport4/decoding_test.rb
297
- - test/activesupport4/encoding_test.rb
298
- - test/activesupport4/test_helper.rb
299
- - test/activesupport5/abstract_unit.rb
300
- - test/activesupport5/decoding_test.rb
301
- - test/activesupport5/encoding_test.rb
302
- - test/activesupport5/encoding_test_cases.rb
303
- - test/activesupport5/test_helper.rb
304
- - test/activesupport5/time_zone_test_helpers.rb
305
- - test/activesupport6/abstract_unit.rb
306
- - test/activesupport6/decoding_test.rb
307
- - test/activesupport6/encoding_test.rb
308
- - test/activesupport6/encoding_test_cases.rb
309
- - test/activesupport6/test_common.rb
310
- - test/activesupport6/test_helper.rb
311
- - test/activesupport6/time_zone_test_helpers.rb
312
- - test/bar.rb
313
- - test/baz.rb
314
- - test/files.rb
315
- - test/foo.rb
316
- - test/helper.rb
317
- - test/isolated/shared.rb
318
- - test/isolated/test_mimic_after.rb
319
- - test/isolated/test_mimic_alone.rb
320
- - test/isolated/test_mimic_as_json.rb
321
- - test/isolated/test_mimic_before.rb
322
- - test/isolated/test_mimic_define.rb
323
- - test/isolated/test_mimic_rails_after.rb
324
- - test/isolated/test_mimic_rails_before.rb
325
- - test/isolated/test_mimic_redefine.rb
326
- - test/json_gem/json_addition_test.rb
327
- - test/json_gem/json_common_interface_test.rb
328
- - test/json_gem/json_encoding_test.rb
329
- - test/json_gem/json_ext_parser_test.rb
330
- - test/json_gem/json_fixtures_test.rb
331
- - test/json_gem/json_generator_test.rb
332
- - test/json_gem/json_generic_object_test.rb
333
- - test/json_gem/json_parser_test.rb
334
- - test/json_gem/json_string_matching_test.rb
335
- - test/json_gem/test_helper.rb
336
- - test/perf.rb
337
- - test/perf_compat.rb
338
- - test/perf_fast.rb
339
- - test/perf_file.rb
340
- - test/perf_object.rb
341
- - test/perf_saj.rb
342
- - test/perf_scp.rb
343
- - test/perf_simple.rb
344
- - test/perf_strict.rb
345
- - test/perf_wab.rb
346
- - test/prec.rb
347
- - test/sample/change.rb
348
- - test/sample/dir.rb
349
- - test/sample/doc.rb
350
- - test/sample/file.rb
351
- - test/sample/group.rb
352
- - test/sample/hasprops.rb
353
- - test/sample/layer.rb
354
- - test/sample/line.rb
355
- - test/sample/oval.rb
356
- - test/sample/rect.rb
357
- - test/sample/shape.rb
358
- - test/sample/text.rb
359
- - test/sample.rb
360
- - test/sample_json.rb
361
- - test/test_compat.rb
362
- - test/test_custom.rb
363
- - test/test_debian.rb
364
- - test/test_fast.rb
365
- - test/test_file.rb
366
- - test/test_gc.rb
367
- - test/test_hash.rb
368
- - test/test_integer_range.rb
369
- - test/test_null.rb
370
- - test/test_object.rb
371
- - test/test_rails.rb
372
- - test/test_saj.rb
373
- - test/test_scp.rb
374
- - test/test_strict.rb
375
- - test/test_various.rb
376
- - test/test_wab.rb
377
- - test/test_writer.rb
378
- - test/tests.rb
379
- - test/tests_mimic.rb
380
- - test/tests_mimic_addition.rb
381
- - test/zoo.rb
329
+ test_files: []
data/ext/oj/hash.c DELETED
@@ -1,135 +0,0 @@
1
- // Copyright (c) 2011 Peter Ohler. All rights reserved.
2
-
3
- #include "hash.h"
4
- #include <stdint.h>
5
-
6
- #define HASH_MASK 0x000003FF
7
- #define HASH_SLOT_CNT 1024
8
-
9
- typedef struct _keyVal {
10
- struct _keyVal *next;
11
- const char *key;
12
- size_t len;
13
- VALUE val;
14
- } *KeyVal;
15
-
16
- struct _hash {
17
- struct _keyVal slots[HASH_SLOT_CNT];
18
- };
19
-
20
- struct _hash class_hash;
21
- struct _hash intern_hash;
22
-
23
- // almost the Murmur hash algorithm
24
- #define M 0x5bd1e995
25
- #define C1 0xCC9E2D51
26
- #define C2 0x1B873593
27
- #define N 0xE6546B64
28
-
29
- static uint32_t
30
- hash_calc(const uint8_t *key, size_t len) {
31
- const uint8_t *end = key + len;
32
- const uint8_t *endless = key + (len / 4 * 4);
33
- uint32_t h = (uint32_t)len;
34
- uint32_t k;
35
-
36
- while (key < endless) {
37
- k = (uint32_t)*key++;
38
- k |= (uint32_t)*key++ << 8;
39
- k |= (uint32_t)*key++ << 16;
40
- k |= (uint32_t)*key++ << 24;
41
-
42
- k *= M;
43
- k ^= k >> 24;
44
- h *= M;
45
- h ^= k * M;
46
- }
47
- if (1 < end - key) {
48
- uint16_t k16 = (uint16_t)*key++;
49
-
50
- k16 |= (uint16_t)*key++ << 8;
51
- h ^= k16 << 8;
52
- }
53
- if (key < end) {
54
- h ^= *key;
55
- }
56
- h *= M;
57
- h ^= h >> 13;
58
- h *= M;
59
- h ^= h >> 15;
60
-
61
- return h;
62
- }
63
-
64
- void
65
- oj_hash_init() {
66
- memset(class_hash.slots, 0, sizeof(class_hash.slots));
67
- memset(intern_hash.slots, 0, sizeof(intern_hash.slots));
68
- }
69
-
70
- // if slotp is 0 then just lookup
71
- static VALUE
72
- hash_get(Hash hash, const char *key, size_t len, VALUE **slotp, VALUE def_value) {
73
- uint32_t h = hash_calc((const uint8_t*)key, len) & HASH_MASK;
74
- KeyVal bucket = hash->slots + h;
75
-
76
- if (0 != bucket->key) {
77
- KeyVal b;
78
-
79
- for (b = bucket; 0 != b; b = b->next) {
80
- if (len == b->len && 0 == strncmp(b->key, key, len)) {
81
- *slotp = &b->val;
82
- return b->val;
83
- }
84
- bucket = b;
85
- }
86
- }
87
- if (0 != slotp) {
88
- if (0 != bucket->key) {
89
- KeyVal b = ALLOC(struct _keyVal);
90
-
91
- b->next = 0;
92
- bucket->next = b;
93
- bucket = b;
94
- }
95
- bucket->key = oj_strndup(key, len);
96
- bucket->len = len;
97
- bucket->val = def_value;
98
- *slotp = &bucket->val;
99
- }
100
- return def_value;
101
- }
102
-
103
- void
104
- oj_hash_print() {
105
- int i;
106
- KeyVal b;
107
-
108
- for (i = 0; i < HASH_SLOT_CNT; i++) {
109
- printf("%4d:", i);
110
- for (b = class_hash.slots + i; 0 != b && 0 != b->key; b = b->next) {
111
- printf(" %s", b->key);
112
- }
113
- printf("\n");
114
- }
115
- }
116
-
117
- VALUE
118
- oj_class_hash_get(const char *key, size_t len, VALUE **slotp) {
119
- return hash_get(&class_hash, key, len, slotp, Qnil);
120
- }
121
-
122
- ID
123
- oj_attr_hash_get(const char *key, size_t len, ID **slotp) {
124
- return (ID)hash_get(&intern_hash, key, len, (VALUE**)slotp, 0);
125
- }
126
-
127
- char*
128
- oj_strndup(const char *s, size_t len) {
129
- char *d = ALLOC_N(char, len + 1);
130
-
131
- memcpy(d, s, len);
132
- d[len] = '\0';
133
-
134
- return d;
135
- }
data/ext/oj/hash.h DELETED
@@ -1,18 +0,0 @@
1
- // Copyright (c) 2011 Peter Ohler. All rights reserved.
2
-
3
- #ifndef OJ_HASH_H
4
- #define OJ_HASH_H
5
-
6
- #include "ruby.h"
7
-
8
- typedef struct _hash *Hash;
9
-
10
- extern void oj_hash_init();
11
-
12
- extern VALUE oj_class_hash_get(const char *key, size_t len, VALUE **slotp);
13
- extern ID oj_attr_hash_get(const char *key, size_t len, ID **slotp);
14
-
15
- extern void oj_hash_print();
16
- extern char* oj_strndup(const char *s, size_t len);
17
-
18
- #endif /* OJ_HASH_H */