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
data/ext/oj/odd.c CHANGED
@@ -1,78 +1,109 @@
1
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 "odd.h"
2
5
 
3
6
  #include <string.h>
4
7
 
5
- #include "odd.h"
8
+ #include "mem.h"
9
+
10
+ static Odd odds = NULL;
11
+ static ID sec_id;
12
+ static ID sec_fraction_id;
13
+ static ID to_f_id;
14
+ static ID numerator_id;
15
+ static ID denominator_id;
16
+ static ID rational_id;
6
17
 
7
- static struct _odd _odds[4]; // bump up if new initial Odd classes are added
8
- static struct _odd *odds = _odds;
9
- static long odd_cnt = 0;
10
- static ID sec_id;
11
- static ID sec_fraction_id;
12
- static ID to_f_id;
13
- static ID numerator_id;
14
- static ID denominator_id;
15
- static ID rational_id;
16
- static VALUE rational_class;
17
-
18
- static void
19
- set_class(Odd odd, const char *classname) {
20
- const char **np;
21
- ID *idp;
18
+ static void set_class(Odd odd, const char *classname) {
19
+ const char **np;
20
+ ID *idp;
22
21
 
23
22
  odd->classname = classname;
24
- odd->clen = strlen(classname);
25
- odd->clas = rb_const_get(rb_cObject, rb_intern(classname));
23
+ odd->clen = strlen(classname);
24
+ odd->clas = rb_const_get(rb_cObject, rb_intern(classname));
25
+ rb_gc_register_mark_object(odd->clas);
26
26
  odd->create_obj = odd->clas;
27
+ rb_gc_register_mark_object(odd->create_obj);
27
28
  odd->create_op = rb_intern("new");
28
29
  odd->is_module = (T_MODULE == rb_type(odd->clas));
29
- odd->raw = 0;
30
+ odd->raw = 0;
30
31
  for (np = odd->attr_names, idp = odd->attrs; 0 != *np; np++, idp++) {
31
- *idp = rb_intern(*np);
32
+ *idp = rb_intern(*np);
32
33
  }
33
34
  *idp = 0;
34
35
  }
35
36
 
36
- static VALUE
37
- get_datetime_secs(VALUE obj) {
38
- volatile VALUE rsecs = rb_funcall(obj, sec_id, 0);
39
- volatile VALUE rfrac = rb_funcall(obj, sec_fraction_id, 0);
40
- long sec = NUM2LONG(rsecs);
41
- long long num = rb_num2ll(rb_funcall(rfrac, numerator_id, 0));
42
- long long den = rb_num2ll(rb_funcall(rfrac, denominator_id, 0));
37
+ static VALUE get_datetime_secs(VALUE obj) {
38
+ volatile VALUE rsecs = rb_funcall(obj, sec_id, 0);
39
+ volatile VALUE rfrac = rb_funcall(obj, sec_fraction_id, 0);
40
+ long sec = NUM2LONG(rsecs);
41
+ long long num = NUM2LL(rb_funcall(rfrac, numerator_id, 0));
42
+ long long den = NUM2LL(rb_funcall(rfrac, denominator_id, 0));
43
43
 
44
44
  num += sec * den;
45
45
 
46
46
  return rb_funcall(rb_cObject, rational_id, 2, rb_ll2inum(num), rb_ll2inum(den));
47
47
  }
48
48
 
49
- void
50
- oj_odd_init() {
51
- Odd odd;
52
- const char **np;
49
+ static void print_odd(Odd odd) {
50
+ const char **np;
51
+ int i;
52
+
53
+ printf(" %s {\n", odd->classname);
54
+ printf(" attr_cnt: %d %p\n", odd->attr_cnt, (void *)odd->attr_names);
55
+ printf(" attr_names: %p\n", (void *)*odd->attr_names);
56
+ printf(" attr_names: %c\n", **odd->attr_names);
57
+ for (i = odd->attr_cnt, np = odd->attr_names; 0 < i; i--, np++) {
58
+ printf(" %d %s\n", i, *np);
59
+ }
60
+ printf(" }\n");
61
+ }
53
62
 
54
- sec_id = rb_intern("sec");
63
+ void print_all_odds(const char *label) {
64
+ Odd odd;
65
+ printf("@ %s {\n", label);
66
+ for (odd = odds; NULL != odd; odd = odd->next) {
67
+ print_odd(odd);
68
+ }
69
+ printf("}\n");
70
+ }
71
+
72
+ static Odd odd_create(void) {
73
+ Odd odd = OJ_R_ALLOC(struct _odd);
74
+
75
+ memset(odd, 0, sizeof(struct _odd));
76
+ odd->next = odds;
77
+ odds = odd;
78
+
79
+ return odd;
80
+ }
81
+
82
+ void oj_odd_init(void) {
83
+ Odd odd;
84
+ const char **np;
85
+
86
+ sec_id = rb_intern("sec");
55
87
  sec_fraction_id = rb_intern("sec_fraction");
56
- to_f_id = rb_intern("to_f");
57
- numerator_id = rb_intern("numerator");
58
- denominator_id = rb_intern("denominator");
59
- rational_id = rb_intern("Rational");
60
- rational_class = rb_const_get(rb_cObject, rational_id);
61
-
62
- memset(_odds, 0, sizeof(_odds));
63
- odd = odds;
88
+ to_f_id = rb_intern("to_f");
89
+ numerator_id = rb_intern("numerator");
90
+ denominator_id = rb_intern("denominator");
91
+ rational_id = rb_intern("Rational");
92
+
64
93
  // Rational
65
- np = odd->attr_names;
94
+ odd = odd_create();
95
+ np = odd->attr_names;
66
96
  *np++ = "numerator";
67
97
  *np++ = "denominator";
68
- *np = 0;
98
+ *np = 0;
69
99
  set_class(odd, "Rational");
70
100
  odd->create_obj = rb_cObject;
71
- odd->create_op = rational_id;
72
- odd->attr_cnt = 2;
101
+ odd->create_op = rational_id;
102
+ odd->attr_cnt = 2;
103
+
73
104
  // Date
74
- odd++;
75
- np = odd->attr_names;
105
+ odd = odd_create();
106
+ np = odd->attr_names;
76
107
  *np++ = "year";
77
108
  *np++ = "month";
78
109
  *np++ = "day";
@@ -80,9 +111,10 @@ oj_odd_init() {
80
111
  *np++ = 0;
81
112
  set_class(odd, "Date");
82
113
  odd->attr_cnt = 4;
114
+
83
115
  // DateTime
84
- odd++;
85
- np = odd->attr_names;
116
+ odd = odd_create();
117
+ np = odd->attr_names;
86
118
  *np++ = "year";
87
119
  *np++ = "month";
88
120
  *np++ = "day";
@@ -93,136 +125,121 @@ oj_odd_init() {
93
125
  *np++ = "start";
94
126
  *np++ = 0;
95
127
  set_class(odd, "DateTime");
96
- odd->attr_cnt = 8;
128
+ odd->attr_cnt = 8;
97
129
  odd->attrFuncs[5] = get_datetime_secs;
130
+
98
131
  // Range
99
- odd++;
100
- np = odd->attr_names;
132
+ odd = odd_create();
133
+ np = odd->attr_names;
101
134
  *np++ = "begin";
102
135
  *np++ = "end";
103
136
  *np++ = "exclude_end?";
104
137
  *np++ = 0;
105
138
  set_class(odd, "Range");
106
139
  odd->attr_cnt = 3;
107
-
108
- odd_cnt = odd - odds + 1;
109
140
  }
110
141
 
111
- Odd
112
- oj_get_odd(VALUE clas) {
113
- Odd odd;
114
- const char *classname = NULL;
115
-
116
- for (odd = odds + odd_cnt - 1; odds <= odd; odd--) {
117
- if (clas == odd->clas) {
118
- return odd;
119
- }
120
- if (odd->is_module) {
121
- if (NULL == classname) {
122
- classname = rb_class2name(clas);
123
- }
124
- if (0 == strncmp(odd->classname, classname, odd->clen) &&
125
- ':' == classname[odd->clen]) {
126
- return odd;
127
- }
128
- }
142
+ Odd oj_get_odd(VALUE clas) {
143
+ Odd odd;
144
+ const char *classname = NULL;
145
+
146
+ for (odd = odds; NULL != odd; odd = odd->next) {
147
+ if (clas == odd->clas) {
148
+ return odd;
149
+ }
150
+ if (odd->is_module) {
151
+ if (NULL == classname) {
152
+ classname = rb_class2name(clas);
153
+ }
154
+ if (0 == strncmp(odd->classname, classname, odd->clen) && ':' == classname[odd->clen]) {
155
+ return odd;
156
+ }
157
+ }
129
158
  }
130
159
  return NULL;
131
160
  }
132
161
 
133
- Odd
134
- oj_get_oddc(const char *classname, size_t len) {
135
- Odd odd;
136
-
137
- for (odd = odds + odd_cnt - 1; odds <= odd; odd--) {
138
- if (len == odd->clen && 0 == strncmp(classname, odd->classname, len)) {
139
- return odd;
140
- }
141
- if (odd->is_module &&
142
- 0 == strncmp(odd->classname, classname, odd->clen) &&
143
- ':' == classname[odd->clen]) {
144
- return odd;
145
- }
162
+ Odd oj_get_oddc(const char *classname, size_t len) {
163
+ Odd odd;
164
+
165
+ for (odd = odds; NULL != odd; odd = odd->next) {
166
+ if (len == odd->clen && 0 == strncmp(classname, odd->classname, len)) {
167
+ return odd;
168
+ }
169
+ if (odd->is_module && 0 == strncmp(odd->classname, classname, odd->clen) && ':' == classname[odd->clen]) {
170
+ return odd;
171
+ }
146
172
  }
147
- return 0;
173
+ return NULL;
148
174
  }
149
175
 
150
- OddArgs
151
- oj_odd_alloc_args(Odd odd) {
152
- OddArgs oa = ALLOC_N(struct _oddArgs, 1);
153
- VALUE *a;
154
- int i;
176
+ OddArgs oj_odd_alloc_args(Odd odd) {
177
+ OddArgs oa = OJ_R_ALLOC_N(struct _oddArgs, 1);
178
+ VALUE *a;
179
+ int i;
155
180
 
156
181
  oa->odd = odd;
157
182
  for (i = odd->attr_cnt, a = oa->args; 0 < i; i--, a++) {
158
- *a = Qnil;
183
+ *a = Qnil;
159
184
  }
160
185
  return oa;
161
186
  }
162
187
 
163
- void
164
- oj_odd_free(OddArgs args) {
165
- xfree(args);
188
+ void oj_odd_free(OddArgs args) {
189
+ OJ_R_FREE(args);
166
190
  }
167
191
 
168
- int
169
- oj_odd_set_arg(OddArgs args, const char *key, size_t klen, VALUE value) {
170
- const char **np;
171
- VALUE *vp;
172
- int i;
192
+ int oj_odd_set_arg(OddArgs args, const char *key, size_t klen, VALUE value) {
193
+ const char **np;
194
+ VALUE *vp;
195
+ int i;
173
196
 
174
197
  for (i = args->odd->attr_cnt, np = args->odd->attr_names, vp = args->args; 0 < i; i--, np++, vp++) {
175
- if (0 == strncmp(key, *np, klen) && '\0' == *((*np) + klen)) {
176
- *vp = value;
177
- return 0;
178
- }
198
+ if (0 == strncmp(key, *np, klen) && '\0' == *((*np) + klen)) {
199
+ *vp = value;
200
+ return 0;
201
+ }
179
202
  }
180
203
  return -1;
181
204
  }
182
205
 
183
- void
184
- oj_reg_odd(VALUE clas, VALUE create_object, VALUE create_method, int mcnt, VALUE *members, bool raw) {
185
- Odd odd;
186
- const char **np;
187
- ID *ap;
188
- AttrGetFunc *fp;
189
-
190
- if (_odds == odds) {
191
- odds = ALLOC_N(struct _odd, odd_cnt + 1);
206
+ void oj_reg_odd(VALUE clas, VALUE create_object, VALUE create_method, int mcnt, VALUE *members, bool raw) {
207
+ Odd odd;
208
+ const char **np;
209
+ ID *ap;
210
+ AttrGetFunc *fp;
192
211
 
193
- memcpy(odds, _odds, sizeof(struct _odd) * odd_cnt);
194
- } else {
195
- REALLOC_N(odds, struct _odd, odd_cnt + 1);
196
- }
197
- odd = odds + odd_cnt;
212
+ odd = odd_create();
198
213
  odd->clas = clas;
199
- if (NULL == (odd->classname = strdup(rb_class2name(clas)))) {
200
- rb_raise(rb_eNoMemError, "for attribute name.");
214
+ rb_gc_register_mark_object(odd->clas);
215
+ if (NULL == (odd->classname = OJ_STRDUP(rb_class2name(clas)))) {
216
+ rb_raise(rb_eNoMemError, "for class name.");
201
217
  }
202
- odd->clen = strlen(odd->classname);
218
+ odd->clen = strlen(odd->classname);
203
219
  odd->create_obj = create_object;
220
+ rb_gc_register_mark_object(odd->create_obj);
204
221
  odd->create_op = SYM2ID(create_method);
205
- odd->attr_cnt = mcnt;
222
+ odd->attr_cnt = mcnt;
206
223
  odd->is_module = (T_MODULE == rb_type(clas));
207
- odd->raw = raw;
224
+ odd->raw = raw;
208
225
  for (ap = odd->attrs, np = odd->attr_names, fp = odd->attrFuncs; 0 < mcnt; mcnt--, ap++, np++, members++, fp++) {
209
- *fp = 0;
210
- switch (rb_type(*members)) {
211
- case T_STRING:
212
- if (NULL == (*np = strdup(rb_string_value_ptr(members)))) {
213
- rb_raise(rb_eNoMemError, "for attribute name.");
214
- }
215
- break;
216
- case T_SYMBOL:
217
- *np = rb_id2name(SYM2ID(*members));
218
- break;
219
- default:
220
- rb_raise(rb_eArgError, "registered member identifiers must be Strings or Symbols.");
221
- break;
222
- }
223
- *ap = rb_intern(*np);
226
+ *fp = 0;
227
+ switch (rb_type(*members)) {
228
+ case T_STRING:
229
+ if (NULL == (*np = OJ_STRDUP(RSTRING_PTR(*members)))) {
230
+ rb_raise(rb_eNoMemError, "for attribute name.");
231
+ }
232
+ break;
233
+ case T_SYMBOL:
234
+ // The symbol can move and invalidate the name so make a copy.
235
+ if (NULL == (*np = OJ_STRDUP(rb_id2name(SYM2ID(*members))))) {
236
+ rb_raise(rb_eNoMemError, "for attribute name.");
237
+ }
238
+ break;
239
+ default: rb_raise(rb_eArgError, "registered member identifiers must be Strings or Symbols."); break;
240
+ }
241
+ *ap = rb_intern(*np);
224
242
  }
225
243
  *np = 0;
226
244
  *ap = 0;
227
- odd_cnt++;
228
245
  }
data/ext/oj/odd.h CHANGED
@@ -1,4 +1,5 @@
1
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.
2
3
 
3
4
  #ifndef OJ_ODD_H
4
5
  #define OJ_ODD_H
@@ -7,35 +8,36 @@
7
8
 
8
9
  #include "ruby.h"
9
10
 
10
- #define MAX_ODD_ARGS 10
11
+ #define MAX_ODD_ARGS 10
11
12
 
12
- typedef VALUE (*AttrGetFunc)(VALUE obj);
13
+ typedef VALUE (*AttrGetFunc)(VALUE obj);
13
14
 
14
15
  typedef struct _odd {
15
- const char *classname;
16
- size_t clen;
17
- VALUE clas; // Ruby class or module
18
- VALUE create_obj;
19
- ID create_op;
20
- int attr_cnt;
21
- bool is_module;
22
- bool raw;
23
- const char *attr_names[MAX_ODD_ARGS]; // NULL terminated attr names
24
- ID attrs[MAX_ODD_ARGS]; // 0 terminated attr IDs
25
- AttrGetFunc attrFuncs[MAX_ODD_ARGS];
16
+ struct _odd *next;
17
+ const char *classname;
18
+ size_t clen;
19
+ VALUE clas; // Ruby class or module
20
+ VALUE create_obj;
21
+ ID create_op;
22
+ int attr_cnt;
23
+ bool is_module;
24
+ bool raw;
25
+ const char *attr_names[MAX_ODD_ARGS]; // NULL terminated attr names
26
+ ID attrs[MAX_ODD_ARGS]; // 0 terminated attr IDs
27
+ AttrGetFunc attrFuncs[MAX_ODD_ARGS];
26
28
  } *Odd;
27
29
 
28
30
  typedef struct _oddArgs {
29
- Odd odd;
30
- VALUE args[MAX_ODD_ARGS];
31
+ Odd odd;
32
+ VALUE args[MAX_ODD_ARGS];
31
33
  } *OddArgs;
32
34
 
33
- extern void oj_odd_init(void);
34
- extern Odd oj_get_odd(VALUE clas);
35
- extern Odd oj_get_oddc(const char *classname, size_t len);
36
- extern OddArgs oj_odd_alloc_args(Odd odd);
37
- extern void oj_odd_free(OddArgs args);
38
- extern int oj_odd_set_arg(OddArgs args, const char *key, size_t klen, VALUE value);
39
- extern void oj_reg_odd(VALUE clas, VALUE create_object, VALUE create_method, int mcnt, VALUE *members, bool raw);
35
+ extern void oj_odd_init(void);
36
+ extern Odd oj_get_odd(VALUE clas);
37
+ extern Odd oj_get_oddc(const char *classname, size_t len);
38
+ extern OddArgs oj_odd_alloc_args(Odd odd);
39
+ extern void oj_odd_free(OddArgs args);
40
+ extern int oj_odd_set_arg(OddArgs args, const char *key, size_t klen, VALUE value);
41
+ extern void oj_reg_odd(VALUE clas, VALUE create_object, VALUE create_method, int mcnt, VALUE *members, bool raw);
40
42
 
41
43
  #endif /* OJ_ODD_H */