oj 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +17 -23
  3. data/README.md +74 -425
  4. data/ext/oj/buf.h +103 -0
  5. data/ext/oj/cache8.c +4 -0
  6. data/ext/oj/circarray.c +68 -0
  7. data/ext/oj/circarray.h +23 -0
  8. data/ext/oj/code.c +227 -0
  9. data/ext/oj/code.h +40 -0
  10. data/ext/oj/compat.c +243 -0
  11. data/ext/oj/custom.c +1097 -0
  12. data/ext/oj/dump.c +766 -1534
  13. data/ext/oj/dump.h +92 -0
  14. data/ext/oj/dump_compat.c +937 -0
  15. data/ext/oj/dump_leaf.c +254 -0
  16. data/ext/oj/dump_object.c +810 -0
  17. data/ext/oj/dump_rails.c +329 -0
  18. data/ext/oj/dump_strict.c +416 -0
  19. data/ext/oj/encode.h +51 -0
  20. data/ext/oj/err.c +57 -0
  21. data/ext/oj/err.h +70 -0
  22. data/ext/oj/extconf.rb +17 -7
  23. data/ext/oj/fast.c +213 -180
  24. data/ext/oj/hash.c +163 -0
  25. data/ext/oj/hash.h +46 -0
  26. data/ext/oj/hash_test.c +512 -0
  27. data/ext/oj/mimic_json.c +817 -0
  28. data/ext/oj/mimic_rails.c +806 -0
  29. data/ext/oj/mimic_rails.h +17 -0
  30. data/ext/oj/object.c +752 -0
  31. data/ext/oj/odd.c +230 -0
  32. data/ext/oj/odd.h +44 -0
  33. data/ext/oj/oj.c +1288 -929
  34. data/ext/oj/oj.h +240 -69
  35. data/ext/oj/parse.c +1014 -0
  36. data/ext/oj/parse.h +92 -0
  37. data/ext/oj/reader.c +223 -0
  38. data/ext/oj/reader.h +151 -0
  39. data/ext/oj/resolve.c +127 -0
  40. data/ext/oj/{cache.h → resolve.h} +6 -13
  41. data/ext/oj/rxclass.c +133 -0
  42. data/ext/oj/rxclass.h +27 -0
  43. data/ext/oj/saj.c +77 -175
  44. data/ext/oj/scp.c +224 -0
  45. data/ext/oj/sparse.c +911 -0
  46. data/ext/oj/stream_writer.c +301 -0
  47. data/ext/oj/strict.c +162 -0
  48. data/ext/oj/string_writer.c +480 -0
  49. data/ext/oj/val_stack.c +98 -0
  50. data/ext/oj/val_stack.h +188 -0
  51. data/lib/oj/active_support_helper.rb +41 -0
  52. data/lib/oj/bag.rb +6 -10
  53. data/lib/oj/easy_hash.rb +52 -0
  54. data/lib/oj/json.rb +172 -0
  55. data/lib/oj/mimic.rb +260 -5
  56. data/lib/oj/saj.rb +13 -10
  57. data/lib/oj/schandler.rb +142 -0
  58. data/lib/oj/state.rb +131 -0
  59. data/lib/oj/version.rb +1 -1
  60. data/lib/oj.rb +11 -23
  61. data/pages/Advanced.md +22 -0
  62. data/pages/Compatibility.md +25 -0
  63. data/pages/Custom.md +23 -0
  64. data/pages/Encoding.md +65 -0
  65. data/pages/JsonGem.md +79 -0
  66. data/pages/Modes.md +140 -0
  67. data/pages/Options.md +250 -0
  68. data/pages/Rails.md +60 -0
  69. data/pages/Security.md +20 -0
  70. data/test/_test_active.rb +76 -0
  71. data/test/_test_active_mimic.rb +96 -0
  72. data/test/_test_mimic_rails.rb +126 -0
  73. data/test/activesupport4/decoding_test.rb +105 -0
  74. data/test/activesupport4/encoding_test.rb +531 -0
  75. data/test/activesupport4/test_helper.rb +41 -0
  76. data/test/activesupport5/decoding_test.rb +125 -0
  77. data/test/activesupport5/encoding_test.rb +483 -0
  78. data/test/activesupport5/encoding_test_cases.rb +90 -0
  79. data/test/activesupport5/test_helper.rb +50 -0
  80. data/test/activesupport5/time_zone_test_helpers.rb +24 -0
  81. data/test/helper.rb +27 -0
  82. data/test/isolated/shared.rb +310 -0
  83. data/test/isolated/test_mimic_after.rb +13 -0
  84. data/test/isolated/test_mimic_alone.rb +12 -0
  85. data/test/isolated/test_mimic_as_json.rb +45 -0
  86. data/test/isolated/test_mimic_before.rb +13 -0
  87. data/test/isolated/test_mimic_define.rb +28 -0
  88. data/test/isolated/test_mimic_rails_after.rb +22 -0
  89. data/test/isolated/test_mimic_rails_before.rb +21 -0
  90. data/test/isolated/test_mimic_redefine.rb +15 -0
  91. data/test/json_gem/json_addition_test.rb +216 -0
  92. data/test/json_gem/json_common_interface_test.rb +143 -0
  93. data/test/json_gem/json_encoding_test.rb +109 -0
  94. data/test/json_gem/json_ext_parser_test.rb +20 -0
  95. data/test/json_gem/json_fixtures_test.rb +35 -0
  96. data/test/json_gem/json_generator_test.rb +383 -0
  97. data/test/json_gem/json_generic_object_test.rb +90 -0
  98. data/test/json_gem/json_parser_test.rb +470 -0
  99. data/test/json_gem/json_string_matching_test.rb +42 -0
  100. data/test/json_gem/test_helper.rb +18 -0
  101. data/test/perf_compat.rb +130 -0
  102. data/test/perf_fast.rb +9 -9
  103. data/test/perf_file.rb +64 -0
  104. data/test/{perf_obj.rb → perf_object.rb} +24 -10
  105. data/test/perf_scp.rb +151 -0
  106. data/test/perf_strict.rb +32 -113
  107. data/test/sample.rb +2 -3
  108. data/test/test_compat.rb +474 -0
  109. data/test/test_custom.rb +355 -0
  110. data/test/test_debian.rb +53 -0
  111. data/test/test_fast.rb +66 -16
  112. data/test/test_file.rb +237 -0
  113. data/test/test_gc.rb +49 -0
  114. data/test/test_hash.rb +29 -0
  115. data/test/test_null.rb +376 -0
  116. data/test/test_object.rb +1010 -0
  117. data/test/test_saj.rb +16 -16
  118. data/test/test_scp.rb +417 -0
  119. data/test/test_strict.rb +410 -0
  120. data/test/test_various.rb +815 -0
  121. data/test/test_writer.rb +308 -0
  122. data/test/tests.rb +9 -902
  123. data/test/tests_mimic.rb +14 -0
  124. data/test/tests_mimic_addition.rb +7 -0
  125. metadata +253 -38
  126. data/ext/oj/cache.c +0 -148
  127. data/ext/oj/foo.rb +0 -6
  128. data/ext/oj/load.c +0 -1049
  129. data/test/a.rb +0 -38
  130. data/test/perf1.rb +0 -64
  131. data/test/perf2.rb +0 -76
  132. data/test/perf_obj_old.rb +0 -213
  133. data/test/test_mimic.rb +0 -208
data/ext/oj/oj.h CHANGED
@@ -1,31 +1,6 @@
1
1
  /* oj.h
2
2
  * Copyright (c) 2011, Peter Ohler
3
3
  * All rights reserved.
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * - Redistributions of source code must retain the above copyright notice, this
9
- * list of conditions and the following disclaimer.
10
- *
11
- * - Redistributions in binary form must reproduce the above copyright notice,
12
- * this list of conditions and the following disclaimer in the documentation
13
- * and/or other materials provided with the distribution.
14
- *
15
- * - Neither the name of Peter Ohler nor the names of its contributors may be
16
- * used to endorse or promote products derived from this software without
17
- * specific prior written permission.
18
- *
19
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
4
  */
30
5
 
31
6
  #ifndef __OJ_H__
@@ -45,11 +20,13 @@ extern "C" {
45
20
  #include "ruby/encoding.h"
46
21
  #endif
47
22
 
48
- #include "stdint.h"
49
- #if SAFE_CACHE
23
+ #include <stdint.h>
24
+ #include <stdbool.h>
25
+
26
+ #if USE_PTHREAD_MUTEX
50
27
  #include <pthread.h>
51
28
  #endif
52
- #include "cache.h"
29
+ #include "cache8.h"
53
30
 
54
31
  #ifdef RUBINIUS_RUBY
55
32
  #undef T_RATIONAL
@@ -64,9 +41,12 @@ enum st_retval {ST_CONTINUE = 0, ST_STOP = 1, ST_DELETE = 2, ST_CHECK};
64
41
  #endif
65
42
  #endif
66
43
 
67
- #define raise_error(msg, xml, current) _oj_raise_error(msg, xml, current, __FILE__, __LINE__)
44
+ #include "rxclass.h"
45
+ #include "err.h"
68
46
 
69
- #define MAX_ODD_ARGS 10
47
+ #define INF_VAL "3.0e14159265358979323846"
48
+ #define NINF_VAL "-3.0e14159265358979323846"
49
+ #define NAN_VAL "3.3e14159265358979323846"
70
50
 
71
51
  typedef enum {
72
52
  Yes = 'y',
@@ -78,53 +58,165 @@ typedef enum {
78
58
  StrictMode = 's',
79
59
  ObjectMode = 'o',
80
60
  NullMode = 'n',
81
- CompatMode = 'c'
61
+ CompatMode = 'c',
62
+ RailsMode = 'r',
63
+ CustomMode = 'C',
82
64
  } Mode;
83
65
 
84
66
  typedef enum {
85
67
  UnixTime = 'u',
68
+ UnixZTime = 'z',
86
69
  XmlTime = 'x',
87
70
  RubyTime = 'r'
88
71
  } TimeFormat;
89
72
 
73
+ typedef enum {
74
+ NLEsc = 'n',
75
+ JSONEsc = 'j',
76
+ XSSEsc = 'x',
77
+ ASCIIEsc = 'a',
78
+ JXEsc = 'r', // json
79
+ RailsEsc = 'R', // rails non escape
80
+ } Encoding;
81
+
82
+ typedef enum {
83
+ BigDec = 'b',
84
+ FloatDec = 'f',
85
+ AutoDec = 'a'
86
+ } BigLoad;
87
+
88
+ typedef enum {
89
+ ArrayNew = 'A',
90
+ ArrayType = 'a',
91
+ ObjectNew = 'O',
92
+ ObjectType = 'o',
93
+ } DumpType;
94
+
95
+ typedef enum {
96
+ AutoNan = 'a',
97
+ NullNan = 'n',
98
+ HugeNan = 'h',
99
+ WordNan = 'w',
100
+ RaiseNan = 'r',
101
+ } NanDump;
102
+
103
+ typedef enum {
104
+ STRING_IO = 'c',
105
+ STREAM_IO = 's',
106
+ FILE_IO = 'f',
107
+ } StreamWriterType;
108
+
109
+ typedef enum {
110
+ CALLER_DUMP = 'd',
111
+ CALLER_TO_JSON = 't',
112
+ CALLER_GENERATE = 'g',
113
+ // Add the fast versions if necessary. Maybe unparse as well if needed.
114
+ } DumpCaller;
115
+
90
116
  typedef struct _DumpOpts {
91
- const char *indent;
92
- const char *before_sep;
93
- const char *after_sep;
94
- const char *hash_nl;
95
- const char *array_nl;
117
+ bool use;
118
+ char indent_str[16];
119
+ char before_sep[16];
120
+ char after_sep[16];
121
+ char hash_nl[16];
122
+ char array_nl[16];
96
123
  uint8_t indent_size;
97
124
  uint8_t before_size;
98
125
  uint8_t after_size;
99
126
  uint8_t hash_size;
100
127
  uint8_t array_size;
128
+ char nan_dump; // NanDump
129
+ bool omit_nil;
130
+ int max_depth;
101
131
  } *DumpOpts;
102
132
 
103
133
  typedef struct _Options {
104
- int indent; // indention for dump, default 2
105
- char circular; // YesNo
106
- char auto_define; // YesNo
107
- char sym_key; // YesNo
108
- char ascii_only; // YesNo
109
- char mode; // Mode
110
- char time_format; // TimeFormat
111
- const char *create_id; // 0 or string
112
- size_t max_stack; // max size to allocate on the stack
113
- DumpOpts dump_opts;
134
+ int indent; // indention for dump, default 2
135
+ char circular; // YesNo
136
+ char auto_define; // YesNo
137
+ char sym_key; // YesNo
138
+ char escape_mode; // Escape_Mode
139
+ char mode; // Mode
140
+ char class_cache; // YesNo
141
+ char time_format; // TimeFormat
142
+ char bigdec_as_num; // YesNo
143
+ char bigdec_load; // BigLoad
144
+ char to_hash; // YesNo
145
+ char to_json; // YesNo
146
+ char as_json; // YesNo
147
+ char nilnil; // YesNo
148
+ char empty_string; // YesNo
149
+ char allow_gc; // allow GC during parse
150
+ char quirks_mode; // allow single JSON values instead of documents
151
+ char allow_invalid; // YesNo - allow invalid unicode
152
+ char create_ok; // YesNo allow create_id
153
+ char allow_nan; // YEsyNo for parsing only
154
+ const char *create_id; // 0 or string
155
+ size_t create_id_len; // length of create_id
156
+ int sec_prec; // second precision when dumping time
157
+ char float_prec; // float precision, linked to float_fmt
158
+ char float_fmt[7]; // float format for dumping, if empty use Ruby
159
+ VALUE hash_class; // class to use in place of Hash on load
160
+ VALUE array_class; // class to use in place of Array on load
161
+ struct _DumpOpts dump_opts;
162
+ struct _RxClass str_rx;
114
163
  } *Options;
115
164
 
116
- typedef struct _Odd {
117
- VALUE clas; // Ruby class
118
- VALUE create_obj;
119
- ID create_op;
120
- int attr_cnt;
121
- ID attrs[MAX_ODD_ARGS]; // 0 terminated attr IDs
122
- } *Odd;
165
+ struct _Out;
166
+ typedef void (*DumpFunc)(VALUE obj, int depth, struct _Out *out, bool as_ok);
167
+
168
+ // rails optimize
169
+ typedef struct _ROpt {
170
+ VALUE clas;
171
+ bool on;
172
+ DumpFunc dump;
173
+ } *ROpt;
174
+
175
+ typedef struct _ROptTable {
176
+ int len;
177
+ int alen;
178
+ ROpt table;
179
+ } *ROptTable;
180
+
181
+ typedef struct _Out {
182
+ char *buf;
183
+ char *end;
184
+ char *cur;
185
+ Cache8 circ_cache;
186
+ slot_t circ_cnt;
187
+ int indent;
188
+ int depth; // used by dump_hash
189
+ Options opts;
190
+ uint32_t hash_cnt;
191
+ int allocated;
192
+ bool omit_nil;
193
+ int argc;
194
+ VALUE *argv;
195
+ DumpCaller caller; // used for the mimic json only
196
+ ROptTable ropts;
197
+ } *Out;
198
+
199
+ typedef struct _StrWriter {
200
+ struct _Out out;
201
+ struct _Options opts;
202
+ int depth;
203
+ char *types; // DumpType
204
+ char *types_end;
205
+ int keyWritten;
206
+ } *StrWriter;
207
+
208
+ typedef struct _StreamWriter {
209
+ struct _StrWriter sw;
210
+ StreamWriterType type;
211
+ VALUE stream;
212
+ int fd;
213
+ } *StreamWriter;
123
214
 
124
215
  enum {
125
- STR_VAL = 0x00,
126
- COL_VAL = 0x01,
127
- RUBY_VAL = 0x02
216
+ NO_VAL = 0x00,
217
+ STR_VAL = 0x01,
218
+ COL_VAL = 0x02,
219
+ RUBY_VAL = 0x03
128
220
  };
129
221
 
130
222
  typedef struct _Leaf {
@@ -134,56 +226,129 @@ typedef struct _Leaf {
134
226
  size_t index; // array index, 0 is not set
135
227
  };
136
228
  union {
137
- char *str; // pointer to location in json string
229
+ char *str; // pointer to location in json string or allocated
138
230
  struct _Leaf *elements; // array and hash elements
139
231
  VALUE value;
140
232
  };
141
- uint8_t type;
233
+ uint8_t rtype;
142
234
  uint8_t parent_type;
143
235
  uint8_t value_type;
144
236
  } *Leaf;
145
237
 
146
- extern VALUE oj_parse(char *json, Options options);
147
- extern void oj_saj_parse(VALUE handler, char *json);
238
+ extern VALUE oj_saj_parse(int argc, VALUE *argv, VALUE self);
239
+ extern VALUE oj_sc_parse(int argc, VALUE *argv, VALUE self);
240
+
241
+ extern VALUE oj_strict_parse(int argc, VALUE *argv, VALUE self);
242
+ extern VALUE oj_strict_sparse(int argc, VALUE *argv, VALUE self);
243
+ extern VALUE oj_compat_parse(int argc, VALUE *argv, VALUE self);
244
+ extern VALUE oj_object_parse(int argc, VALUE *argv, VALUE self);
245
+ extern VALUE oj_custom_parse(int argc, VALUE *argv, VALUE self);
148
246
 
149
- extern char* oj_write_obj_to_str(VALUE obj, Options copts);
247
+ extern VALUE oj_strict_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
248
+ extern VALUE oj_compat_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
249
+ extern VALUE oj_object_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
250
+ extern VALUE oj_custom_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
251
+
252
+ extern void oj_parse_options(VALUE ropts, Options copts);
253
+
254
+ extern void oj_dump_obj_to_json(VALUE obj, Options copts, Out out);
255
+ extern void oj_dump_obj_to_json_using_params(VALUE obj, Options copts, Out out, int argc, VALUE *argv);
150
256
  extern void oj_write_obj_to_file(VALUE obj, const char *path, Options copts);
151
- extern char* oj_write_leaf_to_str(Leaf leaf, Options copts);
257
+ extern void oj_write_obj_to_stream(VALUE obj, VALUE stream, Options copts);
258
+ extern void oj_dump_leaf_to_json(Leaf leaf, Options copts, Out out);
152
259
  extern void oj_write_leaf_to_file(Leaf leaf, const char *path, Options copts);
153
260
 
154
- extern void _oj_raise_error(const char *msg, const char *xml, const char *current, const char* file, int line);
261
+ extern void oj_str_writer_push_key(StrWriter sw, const char *key);
262
+ extern void oj_str_writer_push_object(StrWriter sw, const char *key);
263
+ extern void oj_str_writer_push_array(StrWriter sw, const char *key);
264
+ extern void oj_str_writer_push_value(StrWriter sw, VALUE val, const char *key);
265
+ extern void oj_str_writer_push_json(StrWriter sw, const char *json, const char *key);
266
+ extern void oj_str_writer_pop(StrWriter sw);
267
+ extern void oj_str_writer_pop_all(StrWriter sw);
155
268
 
156
269
  extern void oj_init_doc(void);
270
+ extern void oj_string_writer_init();
271
+ extern void oj_stream_writer_init();
272
+ extern void oj_str_writer_init(StrWriter sw);
273
+ extern VALUE oj_define_mimic_json(int argc, VALUE *argv, VALUE self);
274
+ extern VALUE oj_mimic_generate(int argc, VALUE *argv, VALUE self);
275
+ extern VALUE oj_mimic_pretty_generate(int argc, VALUE *argv, VALUE self);
276
+ extern void oj_parse_mimic_dump_options(VALUE ropts, Options copts);
277
+
278
+ extern VALUE oj_mimic_parse(int argc, VALUE *argv, VALUE self);
279
+ extern VALUE oj_get_json_err_class(const char *err_classname);
280
+ extern void oj_parse_opt_match_string(RxClass rc, VALUE ropts);
157
281
 
158
- extern Odd oj_get_odd(VALUE clas);
282
+ extern VALUE oj_rails_encode(int argc, VALUE *argv, VALUE self);
159
283
 
160
284
  extern VALUE Oj;
161
285
  extern struct _Options oj_default_options;
162
286
  #if HAS_ENCODING_SUPPORT
163
287
  extern rb_encoding *oj_utf8_encoding;
288
+ #else
289
+ extern VALUE oj_utf8_encoding;
164
290
  #endif
165
291
 
166
292
  extern VALUE oj_bag_class;
167
293
  extern VALUE oj_bigdecimal_class;
294
+ extern VALUE oj_cstack_class;
295
+ extern VALUE oj_date_class;
296
+ extern VALUE oj_datetime_class;
168
297
  extern VALUE oj_doc_class;
169
- extern VALUE oj_parse_error_class;
298
+ extern VALUE oj_enumerable_class;
299
+ extern VALUE oj_json_generator_error_class;
300
+ extern VALUE oj_json_parser_error_class;
301
+ extern VALUE oj_stream_writer_class;
302
+ extern VALUE oj_string_writer_class;
170
303
  extern VALUE oj_stringio_class;
171
304
  extern VALUE oj_struct_class;
172
- extern VALUE oj_time_class;
305
+
306
+ extern VALUE oj_allow_nan_sym;
307
+ extern VALUE oj_array_class_sym;
308
+ extern VALUE oj_array_nl_sym;
309
+ extern VALUE oj_ascii_only_sym;
310
+ extern VALUE oj_create_additions_sym;
311
+ extern VALUE oj_hash_class_sym;
312
+ extern VALUE oj_indent_sym;
313
+ extern VALUE oj_max_nesting_sym;
314
+ extern VALUE oj_object_class_sym;
315
+ extern VALUE oj_object_nl_sym;
316
+ extern VALUE oj_quirks_mode_sym;
317
+ extern VALUE oj_space_before_sym;
318
+ extern VALUE oj_space_sym;
173
319
 
174
320
  extern VALUE oj_slash_string;
175
321
 
176
322
  extern ID oj_add_value_id;
323
+ extern ID oj_array_append_id;
177
324
  extern ID oj_array_end_id;
178
325
  extern ID oj_array_start_id;
179
326
  extern ID oj_as_json_id;
327
+ extern ID oj_begin_id;
328
+ extern ID oj_end_id;
180
329
  extern ID oj_error_id;
330
+ extern ID oj_exclude_end_id;
331
+ extern ID oj_file_id;
332
+ extern ID oj_fileno_id;
333
+ extern ID oj_ftype_id;
334
+ extern ID oj_has_key_id;
181
335
  extern ID oj_hash_end_id;
336
+ extern ID oj_hash_key_id;
337
+ extern ID oj_hash_set_id;
182
338
  extern ID oj_hash_start_id;
339
+ extern ID oj_iconv_id;
183
340
  extern ID oj_instance_variables_id;
184
341
  extern ID oj_json_create_id;
342
+ extern ID oj_length_id;
185
343
  extern ID oj_new_id;
344
+ extern ID oj_parse_id;
345
+ extern ID oj_pos_id;
346
+ extern ID oj_read_id;
347
+ extern ID oj_readpartial_id;
348
+ extern ID oj_replace_id;
349
+ extern ID oj_stat_id;
186
350
  extern ID oj_string_id;
351
+ extern ID oj_to_h_id;
187
352
  extern ID oj_to_hash_id;
188
353
  extern ID oj_to_json_id;
189
354
  extern ID oj_to_s_id;
@@ -192,14 +357,20 @@ extern ID oj_to_time_id;
192
357
  extern ID oj_tv_nsec_id;
193
358
  extern ID oj_tv_sec_id;
194
359
  extern ID oj_tv_usec_id;
360
+ extern ID oj_utc_id;
195
361
  extern ID oj_utc_offset_id;
362
+ extern ID oj_utcq_id;
363
+ extern ID oj_write_id;
196
364
 
197
- extern Cache oj_class_cache;
198
- extern Cache oj_attr_cache;
365
+ extern bool oj_use_hash_alt;
366
+ extern bool oj_use_array_alt;
199
367
 
200
- #if SAFE_CACHE
368
+ #if USE_PTHREAD_MUTEX
201
369
  extern pthread_mutex_t oj_cache_mutex;
370
+ #elif USE_RB_MUTEX
371
+ extern VALUE oj_cache_mutex;
202
372
  #endif
373
+
203
374
  #if defined(__cplusplus)
204
375
  #if 0
205
376
  { /* satisfy cc-mode */