oj 3.7.4 → 3.13.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1352 -0
  3. data/README.md +29 -8
  4. data/RELEASE_NOTES.md +61 -0
  5. data/ext/oj/buf.h +53 -72
  6. data/ext/oj/cache.c +326 -0
  7. data/ext/oj/cache.h +21 -0
  8. data/ext/oj/cache8.c +61 -64
  9. data/ext/oj/cache8.h +12 -39
  10. data/ext/oj/circarray.c +37 -43
  11. data/ext/oj/circarray.h +16 -17
  12. data/ext/oj/code.c +165 -179
  13. data/ext/oj/code.h +27 -29
  14. data/ext/oj/compat.c +174 -194
  15. data/ext/oj/custom.c +809 -866
  16. data/ext/oj/debug.c +132 -0
  17. data/ext/oj/dump.c +848 -863
  18. data/ext/oj/dump.h +81 -67
  19. data/ext/oj/dump_compat.c +85 -123
  20. data/ext/oj/dump_leaf.c +100 -188
  21. data/ext/oj/dump_object.c +527 -656
  22. data/ext/oj/dump_strict.c +315 -338
  23. data/ext/oj/encode.h +7 -34
  24. data/ext/oj/encoder.c +43 -0
  25. data/ext/oj/err.c +40 -29
  26. data/ext/oj/err.h +48 -48
  27. data/ext/oj/extconf.rb +17 -4
  28. data/ext/oj/fast.c +1070 -1087
  29. data/ext/oj/intern.c +301 -0
  30. data/ext/oj/intern.h +26 -0
  31. data/ext/oj/mimic_json.c +469 -436
  32. data/ext/oj/object.c +525 -593
  33. data/ext/oj/odd.c +154 -138
  34. data/ext/oj/odd.h +37 -38
  35. data/ext/oj/oj.c +1325 -986
  36. data/ext/oj/oj.h +333 -316
  37. data/ext/oj/parse.c +1002 -846
  38. data/ext/oj/parse.h +92 -87
  39. data/ext/oj/parser.c +1557 -0
  40. data/ext/oj/parser.h +91 -0
  41. data/ext/oj/rails.c +888 -878
  42. data/ext/oj/rails.h +11 -14
  43. data/ext/oj/reader.c +141 -147
  44. data/ext/oj/reader.h +73 -89
  45. data/ext/oj/resolve.c +41 -62
  46. data/ext/oj/resolve.h +7 -9
  47. data/ext/oj/rxclass.c +71 -75
  48. data/ext/oj/rxclass.h +18 -19
  49. data/ext/oj/saj.c +443 -486
  50. data/ext/oj/saj2.c +602 -0
  51. data/ext/oj/scp.c +88 -113
  52. data/ext/oj/sparse.c +787 -709
  53. data/ext/oj/stream_writer.c +133 -159
  54. data/ext/oj/strict.c +127 -118
  55. data/ext/oj/string_writer.c +230 -249
  56. data/ext/oj/trace.c +34 -41
  57. data/ext/oj/trace.h +19 -19
  58. data/ext/oj/usual.c +1254 -0
  59. data/ext/oj/util.c +136 -0
  60. data/ext/oj/util.h +20 -0
  61. data/ext/oj/val_stack.c +59 -67
  62. data/ext/oj/val_stack.h +91 -129
  63. data/ext/oj/validate.c +46 -0
  64. data/ext/oj/wab.c +342 -353
  65. data/lib/oj/bag.rb +1 -0
  66. data/lib/oj/easy_hash.rb +5 -4
  67. data/lib/oj/error.rb +1 -1
  68. data/lib/oj/json.rb +1 -1
  69. data/lib/oj/mimic.rb +48 -14
  70. data/lib/oj/saj.rb +20 -6
  71. data/lib/oj/state.rb +8 -7
  72. data/lib/oj/version.rb +2 -2
  73. data/lib/oj.rb +0 -8
  74. data/pages/Compatibility.md +1 -1
  75. data/pages/JsonGem.md +15 -0
  76. data/pages/Modes.md +53 -46
  77. data/pages/Options.md +72 -11
  78. data/pages/Parser.md +309 -0
  79. data/pages/Rails.md +73 -22
  80. data/pages/Security.md +1 -1
  81. data/test/activerecord/result_test.rb +7 -2
  82. data/test/activesupport5/abstract_unit.rb +45 -0
  83. data/test/activesupport5/decoding_test.rb +68 -60
  84. data/test/activesupport5/encoding_test.rb +111 -96
  85. data/test/activesupport5/encoding_test_cases.rb +33 -25
  86. data/test/activesupport5/test_helper.rb +43 -21
  87. data/test/activesupport5/time_zone_test_helpers.rb +18 -3
  88. data/test/activesupport6/abstract_unit.rb +44 -0
  89. data/test/activesupport6/decoding_test.rb +133 -0
  90. data/test/activesupport6/encoding_test.rb +507 -0
  91. data/test/activesupport6/encoding_test_cases.rb +98 -0
  92. data/test/activesupport6/test_common.rb +17 -0
  93. data/test/activesupport6/test_helper.rb +163 -0
  94. data/test/activesupport6/time_zone_test_helpers.rb +39 -0
  95. data/test/activesupport7/abstract_unit.rb +49 -0
  96. data/test/activesupport7/decoding_test.rb +125 -0
  97. data/test/activesupport7/encoding_test.rb +486 -0
  98. data/test/activesupport7/encoding_test_cases.rb +104 -0
  99. data/test/activesupport7/time_zone_test_helpers.rb +47 -0
  100. data/test/bar.rb +6 -12
  101. data/test/baz.rb +16 -0
  102. data/test/bug.rb +16 -0
  103. data/test/foo.rb +69 -75
  104. data/test/helper.rb +16 -0
  105. data/test/json_gem/json_common_interface_test.rb +8 -3
  106. data/test/json_gem/json_generator_test.rb +18 -4
  107. data/test/json_gem/json_parser_test.rb +9 -0
  108. data/test/json_gem/test_helper.rb +12 -0
  109. data/test/mem.rb +33 -0
  110. data/test/perf.rb +1 -1
  111. data/test/perf_dump.rb +50 -0
  112. data/test/perf_once.rb +58 -0
  113. data/test/perf_parser.rb +189 -0
  114. data/test/perf_scp.rb +11 -10
  115. data/test/perf_strict.rb +17 -23
  116. data/test/prec.rb +23 -0
  117. data/test/sample_json.rb +1 -1
  118. data/test/test_compat.rb +46 -10
  119. data/test/test_custom.rb +147 -8
  120. data/test/test_fast.rb +62 -2
  121. data/test/test_file.rb +25 -2
  122. data/test/test_gc.rb +13 -0
  123. data/test/test_generate.rb +21 -0
  124. data/test/test_hash.rb +11 -1
  125. data/test/test_integer_range.rb +7 -2
  126. data/test/test_object.rb +85 -9
  127. data/test/test_parser.rb +27 -0
  128. data/test/test_parser_saj.rb +335 -0
  129. data/test/test_parser_usual.rb +217 -0
  130. data/test/test_rails.rb +35 -0
  131. data/test/test_saj.rb +1 -1
  132. data/test/test_scp.rb +5 -5
  133. data/test/test_strict.rb +26 -1
  134. data/test/test_various.rb +87 -65
  135. data/test/test_wab.rb +2 -0
  136. data/test/test_writer.rb +19 -2
  137. data/test/tests.rb +1 -1
  138. data/test/zoo.rb +13 -0
  139. metadata +60 -110
  140. data/ext/oj/hash.c +0 -163
  141. data/ext/oj/hash.h +0 -46
  142. data/ext/oj/hash_test.c +0 -512
data/ext/oj/odd.c CHANGED
@@ -1,81 +1,107 @@
1
- /* odd.c
2
- * Copyright (c) 2011, Peter Ohler
3
- * All rights reserved.
4
- */
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"
5
5
 
6
6
  #include <string.h>
7
7
 
8
- #include "odd.h"
8
+ static Odd odds = NULL;
9
+ static ID sec_id;
10
+ static ID sec_fraction_id;
11
+ static ID to_f_id;
12
+ static ID numerator_id;
13
+ static ID denominator_id;
14
+ static ID rational_id;
9
15
 
10
- static struct _Odd _odds[4]; // bump up if new initial Odd classes are added
11
- static struct _Odd *odds = _odds;
12
- static long odd_cnt = 0;
13
- static ID sec_id;
14
- static ID sec_fraction_id;
15
- static ID to_f_id;
16
- static ID numerator_id;
17
- static ID denominator_id;
18
- static ID rational_id;
19
- static VALUE rational_class;
20
-
21
- static void
22
- set_class(Odd odd, const char *classname) {
23
- const char **np;
24
- ID *idp;
16
+ static void set_class(Odd odd, const char *classname) {
17
+ const char **np;
18
+ ID *idp;
25
19
 
26
20
  odd->classname = classname;
27
- odd->clen = strlen(classname);
28
- odd->clas = rb_const_get(rb_cObject, rb_intern(classname));
21
+ odd->clen = strlen(classname);
22
+ odd->clas = rb_const_get(rb_cObject, rb_intern(classname));
23
+ rb_gc_register_mark_object(odd->clas);
29
24
  odd->create_obj = odd->clas;
25
+ rb_gc_register_mark_object(odd->create_obj);
30
26
  odd->create_op = rb_intern("new");
31
27
  odd->is_module = (T_MODULE == rb_type(odd->clas));
32
- odd->raw = 0;
28
+ odd->raw = 0;
33
29
  for (np = odd->attr_names, idp = odd->attrs; 0 != *np; np++, idp++) {
34
- *idp = rb_intern(*np);
30
+ *idp = rb_intern(*np);
35
31
  }
36
32
  *idp = 0;
37
33
  }
38
34
 
39
- static VALUE
40
- get_datetime_secs(VALUE obj) {
41
- VALUE rsecs = rb_funcall(obj, sec_id, 0);
42
- VALUE rfrac = rb_funcall(obj, sec_fraction_id, 0);
43
- long sec = NUM2LONG(rsecs);
44
- long long num = rb_num2ll(rb_funcall(rfrac, numerator_id, 0));
45
- long long den = rb_num2ll(rb_funcall(rfrac, denominator_id, 0));
35
+ static VALUE get_datetime_secs(VALUE obj) {
36
+ volatile VALUE rsecs = rb_funcall(obj, sec_id, 0);
37
+ volatile VALUE rfrac = rb_funcall(obj, sec_fraction_id, 0);
38
+ long sec = NUM2LONG(rsecs);
39
+ long long num = NUM2LL(rb_funcall(rfrac, numerator_id, 0));
40
+ long long den = NUM2LL(rb_funcall(rfrac, denominator_id, 0));
46
41
 
47
42
  num += sec * den;
48
43
 
49
44
  return rb_funcall(rb_cObject, rational_id, 2, rb_ll2inum(num), rb_ll2inum(den));
50
45
  }
51
46
 
52
- void
53
- oj_odd_init() {
54
- Odd odd;
55
- const char **np;
47
+ static void print_odd(Odd odd) {
48
+ const char **np;
49
+ int i;
50
+
51
+ printf(" %s {\n", odd->classname);
52
+ printf(" attr_cnt: %d %p\n", odd->attr_cnt, (void *)odd->attr_names);
53
+ printf(" attr_names: %p\n", (void *)*odd->attr_names);
54
+ printf(" attr_names: %c\n", **odd->attr_names);
55
+ for (i = odd->attr_cnt, np = odd->attr_names; 0 < i; i--, np++) {
56
+ printf(" %d %s\n", i, *np);
57
+ }
58
+ printf(" }\n");
59
+ }
60
+
61
+ void print_all_odds(const char *label) {
62
+ Odd odd;
63
+ printf("@ %s {\n", label);
64
+ for (odd = odds; NULL != odd; odd = odd->next) {
65
+ print_odd(odd);
66
+ }
67
+ printf("}\n");
68
+ }
69
+
70
+ static Odd odd_create(void) {
71
+ Odd odd = ALLOC(struct _odd);
72
+
73
+ memset(odd, 0, sizeof(struct _odd));
74
+ odd->next = odds;
75
+ odds = odd;
76
+
77
+ return odd;
78
+ }
56
79
 
57
- sec_id = rb_intern("sec");
80
+ void oj_odd_init(void) {
81
+ Odd odd;
82
+ const char **np;
83
+
84
+ sec_id = rb_intern("sec");
58
85
  sec_fraction_id = rb_intern("sec_fraction");
59
- to_f_id = rb_intern("to_f");
60
- numerator_id = rb_intern("numerator");
61
- denominator_id = rb_intern("denominator");
62
- rational_id = rb_intern("Rational");
63
- rational_class = rb_const_get(rb_cObject, rational_id);
64
-
65
- memset(_odds, 0, sizeof(_odds));
66
- odd = odds;
86
+ to_f_id = rb_intern("to_f");
87
+ numerator_id = rb_intern("numerator");
88
+ denominator_id = rb_intern("denominator");
89
+ rational_id = rb_intern("Rational");
90
+
67
91
  // Rational
68
- np = odd->attr_names;
92
+ odd = odd_create();
93
+ np = odd->attr_names;
69
94
  *np++ = "numerator";
70
95
  *np++ = "denominator";
71
- *np = 0;
96
+ *np = 0;
72
97
  set_class(odd, "Rational");
73
98
  odd->create_obj = rb_cObject;
74
- odd->create_op = rational_id;
75
- odd->attr_cnt = 2;
99
+ odd->create_op = rational_id;
100
+ odd->attr_cnt = 2;
101
+
76
102
  // Date
77
- odd++;
78
- np = odd->attr_names;
103
+ odd = odd_create();
104
+ np = odd->attr_names;
79
105
  *np++ = "year";
80
106
  *np++ = "month";
81
107
  *np++ = "day";
@@ -83,9 +109,10 @@ oj_odd_init() {
83
109
  *np++ = 0;
84
110
  set_class(odd, "Date");
85
111
  odd->attr_cnt = 4;
112
+
86
113
  // DateTime
87
- odd++;
88
- np = odd->attr_names;
114
+ odd = odd_create();
115
+ np = odd->attr_names;
89
116
  *np++ = "year";
90
117
  *np++ = "month";
91
118
  *np++ = "day";
@@ -96,132 +123,121 @@ oj_odd_init() {
96
123
  *np++ = "start";
97
124
  *np++ = 0;
98
125
  set_class(odd, "DateTime");
99
- odd->attr_cnt = 8;
126
+ odd->attr_cnt = 8;
100
127
  odd->attrFuncs[5] = get_datetime_secs;
128
+
101
129
  // Range
102
- odd++;
103
- np = odd->attr_names;
130
+ odd = odd_create();
131
+ np = odd->attr_names;
104
132
  *np++ = "begin";
105
133
  *np++ = "end";
106
134
  *np++ = "exclude_end?";
107
135
  *np++ = 0;
108
136
  set_class(odd, "Range");
109
137
  odd->attr_cnt = 3;
110
-
111
- odd_cnt = odd - odds + 1;
112
138
  }
113
139
 
114
- Odd
115
- oj_get_odd(VALUE clas) {
116
- Odd odd;
117
- const char *classname = NULL;
118
-
119
- for (odd = odds + odd_cnt - 1; odds <= odd; odd--) {
120
- if (clas == odd->clas) {
121
- return odd;
122
- }
123
- if (odd->is_module) {
124
- if (NULL == classname) {
125
- classname = rb_class2name(clas);
126
- }
127
- if (0 == strncmp(odd->classname, classname, odd->clen) &&
128
- ':' == classname[odd->clen]) {
129
- return odd;
130
- }
131
- }
140
+ Odd oj_get_odd(VALUE clas) {
141
+ Odd odd;
142
+ const char *classname = NULL;
143
+
144
+ for (odd = odds; NULL != odd; odd = odd->next) {
145
+ if (clas == odd->clas) {
146
+ return odd;
147
+ }
148
+ if (odd->is_module) {
149
+ if (NULL == classname) {
150
+ classname = rb_class2name(clas);
151
+ }
152
+ if (0 == strncmp(odd->classname, classname, odd->clen) && ':' == classname[odd->clen]) {
153
+ return odd;
154
+ }
155
+ }
132
156
  }
133
157
  return NULL;
134
158
  }
135
159
 
136
- Odd
137
- oj_get_oddc(const char *classname, size_t len) {
138
- Odd odd;
139
-
140
- for (odd = odds + odd_cnt - 1; odds <= odd; odd--) {
141
- if (len == odd->clen && 0 == strncmp(classname, odd->classname, len)) {
142
- return odd;
143
- }
144
- if (odd->is_module &&
145
- 0 == strncmp(odd->classname, classname, odd->clen) &&
146
- ':' == classname[odd->clen]) {
147
- return odd;
148
- }
160
+ Odd oj_get_oddc(const char *classname, size_t len) {
161
+ Odd odd;
162
+
163
+ for (odd = odds; NULL != odd; odd = odd->next) {
164
+ if (len == odd->clen && 0 == strncmp(classname, odd->classname, len)) {
165
+ return odd;
166
+ }
167
+ if (odd->is_module && 0 == strncmp(odd->classname, classname, odd->clen) && ':' == classname[odd->clen]) {
168
+ return odd;
169
+ }
149
170
  }
150
- return 0;
171
+ return NULL;
151
172
  }
152
173
 
153
- OddArgs
154
- oj_odd_alloc_args(Odd odd) {
155
- OddArgs oa = ALLOC_N(struct _OddArgs, 1);
156
- VALUE *a;
157
- int i;
174
+ OddArgs oj_odd_alloc_args(Odd odd) {
175
+ OddArgs oa = ALLOC_N(struct _oddArgs, 1);
176
+ VALUE *a;
177
+ int i;
158
178
 
159
179
  oa->odd = odd;
160
180
  for (i = odd->attr_cnt, a = oa->args; 0 < i; i--, a++) {
161
- *a = Qnil;
181
+ *a = Qnil;
162
182
  }
163
183
  return oa;
164
184
  }
165
185
 
166
- void
167
- oj_odd_free(OddArgs args) {
186
+ void oj_odd_free(OddArgs args) {
168
187
  xfree(args);
169
188
  }
170
189
 
171
- int
172
- oj_odd_set_arg(OddArgs args, const char *key, size_t klen, VALUE value) {
173
- const char **np;
174
- VALUE *vp;
175
- int i;
190
+ int oj_odd_set_arg(OddArgs args, const char *key, size_t klen, VALUE value) {
191
+ const char **np;
192
+ VALUE *vp;
193
+ int i;
176
194
 
177
195
  for (i = args->odd->attr_cnt, np = args->odd->attr_names, vp = args->args; 0 < i; i--, np++, vp++) {
178
- if (0 == strncmp(key, *np, klen) && '\0' == *((*np) + klen)) {
179
- *vp = value;
180
- return 0;
181
- }
196
+ if (0 == strncmp(key, *np, klen) && '\0' == *((*np) + klen)) {
197
+ *vp = value;
198
+ return 0;
199
+ }
182
200
  }
183
201
  return -1;
184
202
  }
185
203
 
186
- void
187
- oj_reg_odd(VALUE clas, VALUE create_object, VALUE create_method, int mcnt, VALUE *members, bool raw) {
188
- Odd odd;
189
- const char **np;
190
- ID *ap;
191
- AttrGetFunc *fp;
204
+ void oj_reg_odd(VALUE clas, VALUE create_object, VALUE create_method, int mcnt, VALUE *members, bool raw) {
205
+ Odd odd;
206
+ const char **np;
207
+ ID *ap;
208
+ AttrGetFunc *fp;
192
209
 
193
- if (_odds == odds) {
194
- odds = ALLOC_N(struct _Odd, odd_cnt + 1);
195
-
196
- memcpy(odds, _odds, sizeof(struct _Odd) * odd_cnt);
197
- } else {
198
- REALLOC_N(odds, struct _Odd, odd_cnt + 1);
199
- }
200
- odd = odds + odd_cnt;
210
+ odd = odd_create();
201
211
  odd->clas = clas;
202
- odd->classname = strdup(rb_class2name(clas));
203
- odd->clen = strlen(odd->classname);
212
+ rb_gc_register_mark_object(odd->clas);
213
+ if (NULL == (odd->classname = strdup(rb_class2name(clas)))) {
214
+ rb_raise(rb_eNoMemError, "for class name.");
215
+ }
216
+ odd->clen = strlen(odd->classname);
204
217
  odd->create_obj = create_object;
218
+ rb_gc_register_mark_object(odd->create_obj);
205
219
  odd->create_op = SYM2ID(create_method);
206
- odd->attr_cnt = mcnt;
220
+ odd->attr_cnt = mcnt;
207
221
  odd->is_module = (T_MODULE == rb_type(clas));
208
- odd->raw = raw;
222
+ odd->raw = raw;
209
223
  for (ap = odd->attrs, np = odd->attr_names, fp = odd->attrFuncs; 0 < mcnt; mcnt--, ap++, np++, members++, fp++) {
210
- *fp = 0;
211
- switch (rb_type(*members)) {
212
- case T_STRING:
213
- *np = strdup(rb_string_value_ptr(members));
214
- break;
215
- case T_SYMBOL:
216
- *np = rb_id2name(SYM2ID(*members));
217
- break;
218
- default:
219
- rb_raise(rb_eArgError, "registered member identifiers must be Strings or Symbols.");
220
- break;
221
- }
222
- *ap = rb_intern(*np);
224
+ *fp = 0;
225
+ switch (rb_type(*members)) {
226
+ case T_STRING:
227
+ if (NULL == (*np = strdup(RSTRING_PTR(*members)))) {
228
+ rb_raise(rb_eNoMemError, "for attribute name.");
229
+ }
230
+ break;
231
+ case T_SYMBOL:
232
+ // The symbol can move and invalidate the name so make a copy.
233
+ if (NULL == (*np = strdup(rb_id2name(SYM2ID(*members))))) {
234
+ rb_raise(rb_eNoMemError, "for attribute name.");
235
+ }
236
+ break;
237
+ default: rb_raise(rb_eArgError, "registered member identifiers must be Strings or Symbols."); break;
238
+ }
239
+ *ap = rb_intern(*np);
223
240
  }
224
241
  *np = 0;
225
242
  *ap = 0;
226
- odd_cnt++;
227
243
  }
data/ext/oj/odd.h CHANGED
@@ -1,44 +1,43 @@
1
- /* odd.h
2
- * Copyright (c) 2011, Peter Ohler
3
- * All rights reserved.
4
- */
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.
5
3
 
6
- #ifndef __OJ_ODD_H__
7
- #define __OJ_ODD_H__
4
+ #ifndef OJ_ODD_H
5
+ #define OJ_ODD_H
8
6
 
9
7
  #include <stdbool.h>
10
8
 
11
9
  #include "ruby.h"
12
10
 
13
- #define MAX_ODD_ARGS 10
14
-
15
- typedef VALUE (*AttrGetFunc)(VALUE obj);
16
-
17
- typedef struct _Odd {
18
- const char *classname;
19
- size_t clen;
20
- VALUE clas; // Ruby class or module
21
- VALUE create_obj;
22
- ID create_op;
23
- int attr_cnt;
24
- bool is_module;
25
- bool raw;
26
- const char *attr_names[MAX_ODD_ARGS]; // NULL terminated attr names
27
- ID attrs[MAX_ODD_ARGS]; // 0 terminated attr IDs
28
- AttrGetFunc attrFuncs[MAX_ODD_ARGS];
29
- } *Odd;
30
-
31
- typedef struct _OddArgs {
32
- Odd odd;
33
- VALUE args[MAX_ODD_ARGS];
34
- } *OddArgs;
35
-
36
- extern void oj_odd_init(void);
37
- extern Odd oj_get_odd(VALUE clas);
38
- extern Odd oj_get_oddc(const char *classname, size_t len);
39
- extern OddArgs oj_odd_alloc_args(Odd odd);
40
- extern void oj_odd_free(OddArgs args);
41
- extern int oj_odd_set_arg(OddArgs args, const char *key, size_t klen, VALUE value);
42
- extern void oj_reg_odd(VALUE clas, VALUE create_object, VALUE create_method, int mcnt, VALUE *members, bool raw);
43
-
44
- #endif /* __OJ_ODD_H__ */
11
+ #define MAX_ODD_ARGS 10
12
+
13
+ typedef VALUE (*AttrGetFunc)(VALUE obj);
14
+
15
+ typedef struct _odd {
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];
28
+ } * Odd;
29
+
30
+ typedef struct _oddArgs {
31
+ Odd odd;
32
+ VALUE args[MAX_ODD_ARGS];
33
+ } * OddArgs;
34
+
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);
42
+
43
+ #endif /* OJ_ODD_H */