oj 3.11.5 → 3.16.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1421 -0
  3. data/README.md +19 -5
  4. data/RELEASE_NOTES.md +61 -0
  5. data/ext/oj/buf.h +20 -6
  6. data/ext/oj/cache.c +329 -0
  7. data/ext/oj/cache.h +22 -0
  8. data/ext/oj/cache8.c +10 -9
  9. data/ext/oj/circarray.c +8 -6
  10. data/ext/oj/circarray.h +2 -2
  11. data/ext/oj/code.c +19 -33
  12. data/ext/oj/code.h +2 -2
  13. data/ext/oj/compat.c +27 -77
  14. data/ext/oj/custom.c +86 -179
  15. data/ext/oj/debug.c +126 -0
  16. data/ext/oj/dump.c +256 -249
  17. data/ext/oj/dump.h +26 -12
  18. data/ext/oj/dump_compat.c +565 -642
  19. data/ext/oj/dump_leaf.c +17 -63
  20. data/ext/oj/dump_object.c +65 -187
  21. data/ext/oj/dump_strict.c +27 -51
  22. data/ext/oj/encoder.c +43 -0
  23. data/ext/oj/err.c +2 -13
  24. data/ext/oj/err.h +24 -8
  25. data/ext/oj/extconf.rb +21 -6
  26. data/ext/oj/fast.c +149 -149
  27. data/ext/oj/intern.c +313 -0
  28. data/ext/oj/intern.h +22 -0
  29. data/ext/oj/mem.c +318 -0
  30. data/ext/oj/mem.h +53 -0
  31. data/ext/oj/mimic_json.c +121 -106
  32. data/ext/oj/object.c +85 -162
  33. data/ext/oj/odd.c +89 -67
  34. data/ext/oj/odd.h +15 -15
  35. data/ext/oj/oj.c +542 -411
  36. data/ext/oj/oj.h +99 -73
  37. data/ext/oj/parse.c +175 -187
  38. data/ext/oj/parse.h +26 -24
  39. data/ext/oj/parser.c +1600 -0
  40. data/ext/oj/parser.h +101 -0
  41. data/ext/oj/rails.c +112 -159
  42. data/ext/oj/rails.h +1 -1
  43. data/ext/oj/reader.c +11 -14
  44. data/ext/oj/reader.h +4 -2
  45. data/ext/oj/resolve.c +5 -24
  46. data/ext/oj/rxclass.c +7 -6
  47. data/ext/oj/rxclass.h +1 -1
  48. data/ext/oj/saj.c +22 -33
  49. data/ext/oj/saj2.c +584 -0
  50. data/ext/oj/saj2.h +23 -0
  51. data/ext/oj/scp.c +5 -28
  52. data/ext/oj/sparse.c +28 -72
  53. data/ext/oj/stream_writer.c +50 -40
  54. data/ext/oj/strict.c +56 -61
  55. data/ext/oj/string_writer.c +72 -39
  56. data/ext/oj/trace.h +31 -4
  57. data/ext/oj/usual.c +1218 -0
  58. data/ext/oj/usual.h +69 -0
  59. data/ext/oj/util.h +1 -1
  60. data/ext/oj/val_stack.c +14 -3
  61. data/ext/oj/val_stack.h +8 -7
  62. data/ext/oj/validate.c +46 -0
  63. data/ext/oj/wab.c +63 -88
  64. data/lib/oj/active_support_helper.rb +1 -3
  65. data/lib/oj/bag.rb +7 -1
  66. data/lib/oj/easy_hash.rb +4 -5
  67. data/lib/oj/error.rb +1 -2
  68. data/lib/oj/json.rb +162 -150
  69. data/lib/oj/mimic.rb +9 -7
  70. data/lib/oj/saj.rb +20 -6
  71. data/lib/oj/schandler.rb +5 -4
  72. data/lib/oj/state.rb +12 -8
  73. data/lib/oj/version.rb +1 -2
  74. data/lib/oj.rb +2 -0
  75. data/pages/Compatibility.md +1 -1
  76. data/pages/InstallOptions.md +20 -0
  77. data/pages/JsonGem.md +15 -0
  78. data/pages/Modes.md +8 -3
  79. data/pages/Options.md +43 -5
  80. data/pages/Parser.md +309 -0
  81. data/pages/Rails.md +14 -2
  82. data/test/_test_active.rb +8 -9
  83. data/test/_test_active_mimic.rb +7 -8
  84. data/test/_test_mimic_rails.rb +17 -20
  85. data/test/activerecord/result_test.rb +5 -6
  86. data/test/activesupport6/encoding_test.rb +63 -28
  87. data/test/{activesupport5 → activesupport7}/abstract_unit.rb +16 -12
  88. data/test/{activesupport5 → activesupport7}/decoding_test.rb +2 -10
  89. data/test/{activesupport5 → activesupport7}/encoding_test.rb +86 -50
  90. data/test/{activesupport5 → activesupport7}/encoding_test_cases.rb +6 -0
  91. data/test/{activesupport5 → activesupport7}/time_zone_test_helpers.rb +8 -0
  92. data/test/files.rb +15 -15
  93. data/test/foo.rb +16 -45
  94. data/test/helper.rb +11 -8
  95. data/test/isolated/shared.rb +3 -2
  96. data/test/json_gem/json_addition_test.rb +2 -2
  97. data/test/json_gem/json_common_interface_test.rb +8 -6
  98. data/test/json_gem/json_encoding_test.rb +0 -0
  99. data/test/json_gem/json_ext_parser_test.rb +1 -0
  100. data/test/json_gem/json_fixtures_test.rb +3 -2
  101. data/test/json_gem/json_generator_test.rb +56 -38
  102. data/test/json_gem/json_generic_object_test.rb +11 -11
  103. data/test/json_gem/json_parser_test.rb +54 -47
  104. data/test/json_gem/json_string_matching_test.rb +9 -9
  105. data/test/json_gem/test_helper.rb +7 -3
  106. data/test/mem.rb +34 -0
  107. data/test/perf.rb +22 -27
  108. data/test/perf_compat.rb +31 -33
  109. data/test/perf_dump.rb +50 -0
  110. data/test/perf_fast.rb +80 -82
  111. data/test/perf_file.rb +27 -29
  112. data/test/perf_object.rb +65 -69
  113. data/test/perf_once.rb +59 -0
  114. data/test/perf_parser.rb +183 -0
  115. data/test/perf_saj.rb +46 -54
  116. data/test/perf_scp.rb +58 -69
  117. data/test/perf_simple.rb +41 -39
  118. data/test/perf_strict.rb +74 -82
  119. data/test/perf_wab.rb +67 -69
  120. data/test/prec.rb +5 -5
  121. data/test/sample/change.rb +0 -1
  122. data/test/sample/dir.rb +0 -1
  123. data/test/sample/doc.rb +0 -1
  124. data/test/sample/file.rb +0 -1
  125. data/test/sample/group.rb +0 -1
  126. data/test/sample/hasprops.rb +0 -1
  127. data/test/sample/layer.rb +0 -1
  128. data/test/sample/rect.rb +0 -1
  129. data/test/sample/shape.rb +0 -1
  130. data/test/sample/text.rb +0 -1
  131. data/test/sample.rb +16 -16
  132. data/test/sample_json.rb +8 -8
  133. data/test/test_compat.rb +95 -43
  134. data/test/test_custom.rb +73 -51
  135. data/test/test_debian.rb +7 -10
  136. data/test/test_fast.rb +135 -79
  137. data/test/test_file.rb +41 -30
  138. data/test/test_gc.rb +16 -5
  139. data/test/test_generate.rb +5 -5
  140. data/test/test_hash.rb +5 -5
  141. data/test/test_integer_range.rb +9 -9
  142. data/test/test_null.rb +20 -20
  143. data/test/test_object.rb +99 -96
  144. data/test/test_parser.rb +11 -0
  145. data/test/test_parser_debug.rb +27 -0
  146. data/test/test_parser_saj.rb +337 -0
  147. data/test/test_parser_usual.rb +251 -0
  148. data/test/test_rails.rb +2 -2
  149. data/test/test_saj.rb +10 -8
  150. data/test/test_scp.rb +37 -39
  151. data/test/test_strict.rb +40 -32
  152. data/test/test_various.rb +165 -84
  153. data/test/test_wab.rb +48 -44
  154. data/test/test_writer.rb +47 -47
  155. data/test/tests.rb +13 -5
  156. data/test/tests_mimic.rb +12 -3
  157. data/test/tests_mimic_addition.rb +12 -3
  158. metadata +74 -128
  159. data/ext/oj/hash.c +0 -131
  160. data/ext/oj/hash.h +0 -19
  161. data/ext/oj/hash_test.c +0 -491
  162. data/test/activesupport4/decoding_test.rb +0 -108
  163. data/test/activesupport4/encoding_test.rb +0 -531
  164. data/test/activesupport4/test_helper.rb +0 -41
  165. data/test/activesupport5/test_helper.rb +0 -72
  166. data/test/bar.rb +0 -35
  167. data/test/baz.rb +0 -16
  168. data/test/zoo.rb +0 -13
data/ext/oj/debug.c ADDED
@@ -0,0 +1,126 @@
1
+ // Copyright (c) 2021, Peter Ohler, All rights reserved.
2
+
3
+ #include "parser.h"
4
+
5
+ static void add_null(struct _ojParser *p) {
6
+ switch (p->stack[p->depth]) {
7
+ case TOP_FUN: printf("*** add_null at top\n"); break;
8
+ case ARRAY_FUN: printf("*** add_null to array\n"); break;
9
+ case OBJECT_FUN: printf("*** add_null with '%s'\n", buf_str(&p->key)); break;
10
+ }
11
+ }
12
+
13
+ static void add_true(struct _ojParser *p) {
14
+ switch (p->stack[p->depth]) {
15
+ case TOP_FUN: printf("*** add_true at top\n"); break;
16
+ case ARRAY_FUN: printf("*** add_true to array\n"); break;
17
+ case OBJECT_FUN: printf("*** add_true with '%s'\n", buf_str(&p->key)); break;
18
+ }
19
+ }
20
+
21
+ static void add_false(struct _ojParser *p) {
22
+ switch (p->stack[p->depth]) {
23
+ case TOP_FUN: printf("*** add_false at top\n"); break;
24
+ case ARRAY_FUN: printf("*** add_false to array\n"); break;
25
+ case OBJECT_FUN: printf("*** add_false with '%s'\n", buf_str(&p->key)); break;
26
+ }
27
+ }
28
+
29
+ static void add_int(struct _ojParser *p) {
30
+ switch (p->stack[p->depth]) {
31
+ case TOP_FUN: printf("*** add_int %lld at top\n", (long long)p->num.fixnum); break;
32
+ case ARRAY_FUN: printf("*** add_int %lld to array\n", (long long)p->num.fixnum); break;
33
+ case OBJECT_FUN: printf("*** add_int %lld with '%s'\n", (long long)p->num.fixnum, buf_str(&p->key)); break;
34
+ }
35
+ }
36
+
37
+ static void add_float(struct _ojParser *p) {
38
+ switch (p->stack[p->depth]) {
39
+ case TOP_FUN: printf("*** add_float %Lf at top\n", p->num.dub); break;
40
+ case ARRAY_FUN: printf("*** add_float %Lf to array\n", p->num.dub); break;
41
+ case OBJECT_FUN: printf("*** add_float %Lf with '%s'\n", p->num.dub, buf_str(&p->key)); break;
42
+ }
43
+ }
44
+
45
+ static void add_big(struct _ojParser *p) {
46
+ switch (p->stack[p->depth]) {
47
+ case TOP_FUN: printf("*** add_big %s at top\n", buf_str(&p->buf)); break;
48
+ case ARRAY_FUN: printf("*** add_big %s to array\n", buf_str(&p->buf)); break;
49
+ case OBJECT_FUN: printf("*** add_big %s with '%s'\n", buf_str(&p->buf), buf_str(&p->key)); break;
50
+ }
51
+ }
52
+
53
+ static void add_str(struct _ojParser *p) {
54
+ switch (p->stack[p->depth]) {
55
+ case TOP_FUN: printf("*** add_str '%s' at top\n", buf_str(&p->buf)); break;
56
+ case ARRAY_FUN: printf("*** add_str '%s' to array\n", buf_str(&p->buf)); break;
57
+ case OBJECT_FUN: printf("*** add_str '%s' with '%s'\n", buf_str(&p->buf), buf_str(&p->key)); break;
58
+ }
59
+ }
60
+
61
+ static void open_array(struct _ojParser *p) {
62
+ switch (p->stack[p->depth]) {
63
+ case TOP_FUN: printf("*** open_array at top\n"); break;
64
+ case ARRAY_FUN: printf("*** open_array to array\n"); break;
65
+ case OBJECT_FUN: printf("*** open_array with '%s'\n", buf_str(&p->key)); break;
66
+ }
67
+ }
68
+
69
+ static void close_array(struct _ojParser *p) {
70
+ printf("*** close_array\n");
71
+ }
72
+
73
+ static void open_object(struct _ojParser *p) {
74
+ switch (p->stack[p->depth]) {
75
+ case TOP_FUN: printf("*** open_object at top\n"); break;
76
+ case ARRAY_FUN: printf("*** open_object to array\n"); break;
77
+ case OBJECT_FUN: printf("*** open_object with '%s'\n", buf_str(&p->key)); break;
78
+ }
79
+ }
80
+
81
+ static void close_object(struct _ojParser *p) {
82
+ printf("*** close_object\n");
83
+ }
84
+
85
+ static VALUE option(ojParser p, const char *key, VALUE value) {
86
+ rb_raise(rb_eArgError, "%s is not an option for the debug delegate", key);
87
+ return Qnil;
88
+ }
89
+
90
+ static VALUE result(struct _ojParser *p) {
91
+ return Qnil;
92
+ }
93
+
94
+ static void start(struct _ojParser *p) {
95
+ printf("*** start\n");
96
+ }
97
+
98
+ static void dfree(struct _ojParser *p) {
99
+ }
100
+
101
+ static void mark(struct _ojParser *p) {
102
+ }
103
+
104
+ void oj_set_parser_debug(ojParser p) {
105
+ Funcs end = p->funcs + 3;
106
+ Funcs f;
107
+
108
+ for (f = p->funcs; f < end; f++) {
109
+ f->add_null = add_null;
110
+ f->add_true = add_true;
111
+ f->add_false = add_false;
112
+ f->add_int = add_int;
113
+ f->add_float = add_float;
114
+ f->add_big = add_big;
115
+ f->add_str = add_str;
116
+ f->open_array = open_array;
117
+ f->close_array = close_array;
118
+ f->open_object = open_object;
119
+ f->close_object = close_object;
120
+ }
121
+ p->option = option;
122
+ p->result = result;
123
+ p->free = dfree;
124
+ p->mark = mark;
125
+ p->start = start;
126
+ }