oj 3.10.6 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -1
  3. data/ext/oj/buf.h +36 -68
  4. data/ext/oj/cache8.c +59 -62
  5. data/ext/oj/cache8.h +9 -36
  6. data/ext/oj/circarray.c +36 -42
  7. data/ext/oj/circarray.h +12 -13
  8. data/ext/oj/code.c +172 -179
  9. data/ext/oj/code.h +22 -24
  10. data/ext/oj/compat.c +168 -181
  11. data/ext/oj/custom.c +800 -864
  12. data/ext/oj/dump.c +774 -776
  13. data/ext/oj/dump.h +50 -55
  14. data/ext/oj/dump_compat.c +2 -4
  15. data/ext/oj/dump_leaf.c +118 -162
  16. data/ext/oj/dump_object.c +610 -632
  17. data/ext/oj/dump_strict.c +319 -331
  18. data/ext/oj/encode.h +4 -33
  19. data/ext/oj/err.c +40 -29
  20. data/ext/oj/err.h +25 -44
  21. data/ext/oj/extconf.rb +2 -1
  22. data/ext/oj/fast.c +1054 -1081
  23. data/ext/oj/hash.c +78 -95
  24. data/ext/oj/hash.h +10 -35
  25. data/ext/oj/hash_test.c +451 -472
  26. data/ext/oj/mimic_json.c +415 -402
  27. data/ext/oj/object.c +588 -532
  28. data/ext/oj/odd.c +124 -132
  29. data/ext/oj/odd.h +28 -29
  30. data/ext/oj/oj.c +1178 -905
  31. data/ext/oj/oj.h +289 -298
  32. data/ext/oj/parse.c +946 -870
  33. data/ext/oj/parse.h +81 -79
  34. data/ext/oj/rails.c +837 -842
  35. data/ext/oj/rails.h +8 -11
  36. data/ext/oj/reader.c +139 -147
  37. data/ext/oj/reader.h +68 -84
  38. data/ext/oj/resolve.c +44 -47
  39. data/ext/oj/resolve.h +4 -6
  40. data/ext/oj/rxclass.c +69 -73
  41. data/ext/oj/rxclass.h +13 -14
  42. data/ext/oj/saj.c +453 -484
  43. data/ext/oj/scp.c +88 -113
  44. data/ext/oj/sparse.c +783 -714
  45. data/ext/oj/stream_writer.c +123 -157
  46. data/ext/oj/strict.c +133 -106
  47. data/ext/oj/string_writer.c +199 -247
  48. data/ext/oj/trace.c +34 -41
  49. data/ext/oj/trace.h +15 -15
  50. data/ext/oj/util.c +104 -104
  51. data/ext/oj/util.h +4 -3
  52. data/ext/oj/val_stack.c +48 -76
  53. data/ext/oj/val_stack.h +80 -115
  54. data/ext/oj/wab.c +317 -328
  55. data/lib/oj.rb +0 -8
  56. data/lib/oj/bag.rb +1 -0
  57. data/lib/oj/easy_hash.rb +5 -4
  58. data/lib/oj/mimic.rb +45 -13
  59. data/lib/oj/version.rb +1 -1
  60. data/pages/Modes.md +1 -0
  61. data/pages/Options.md +23 -11
  62. data/test/activerecord/result_test.rb +7 -2
  63. data/test/foo.rb +8 -40
  64. data/test/helper.rb +10 -0
  65. data/test/json_gem/json_common_interface_test.rb +8 -3
  66. data/test/json_gem/json_generator_test.rb +15 -3
  67. data/test/json_gem/test_helper.rb +8 -0
  68. data/test/perf.rb +1 -1
  69. data/test/perf_scp.rb +11 -10
  70. data/test/perf_strict.rb +17 -23
  71. data/test/prec.rb +23 -0
  72. data/test/sample_json.rb +1 -1
  73. data/test/test_compat.rb +16 -3
  74. data/test/test_custom.rb +11 -0
  75. data/test/test_fast.rb +32 -2
  76. data/test/test_generate.rb +21 -0
  77. data/test/test_hash.rb +10 -0
  78. data/test/test_rails.rb +9 -0
  79. data/test/test_scp.rb +1 -1
  80. data/test/test_various.rb +4 -2
  81. metadata +89 -85
data/ext/oj/oj.h CHANGED
@@ -1,7 +1,5 @@
1
- /* oj.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
4
  #ifndef OJ_H
7
5
  #define OJ_H
@@ -15,12 +13,12 @@ extern "C" {
15
13
 
16
14
  #define RSTRING_NOT_MODIFIED
17
15
 
16
+ #include <stdbool.h>
17
+ #include <stdint.h>
18
+
18
19
  #include "ruby.h"
19
20
  #include "ruby/encoding.h"
20
21
 
21
- #include <stdint.h>
22
- #include <stdbool.h>
23
-
24
22
  #ifdef HAVE_PTHREAD_MUTEX_INIT
25
23
  #include <pthread.h>
26
24
  #endif
@@ -29,359 +27,352 @@ extern "C" {
29
27
  #ifdef RUBINIUS_RUBY
30
28
  #undef T_RATIONAL
31
29
  #undef T_COMPLEX
32
- enum st_retval {ST_CONTINUE = 0, ST_STOP = 1, ST_DELETE = 2, ST_CHECK};
30
+ enum st_retval { ST_CONTINUE = 0, ST_STOP = 1, ST_DELETE = 2, ST_CHECK };
33
31
  #else
34
32
  #include "ruby/st.h"
35
33
  #endif
36
34
 
37
- #include "rxclass.h"
38
35
  #include "err.h"
36
+ #include "rxclass.h"
39
37
 
40
- #define INF_VAL "3.0e14159265358979323846"
41
- #define NINF_VAL "-3.0e14159265358979323846"
42
- #define NAN_VAL "3.3e14159265358979323846"
38
+ #define INF_VAL "3.0e14159265358979323846"
39
+ #define NINF_VAL "-3.0e14159265358979323846"
40
+ #define NAN_VAL "3.3e14159265358979323846"
43
41
 
44
- typedef enum {
45
- Yes = 'y',
46
- No = 'n',
47
- NotSet = 0
48
- } YesNo;
42
+ typedef enum { Yes = 'y', No = 'n', NotSet = 0 } YesNo;
49
43
 
50
44
  typedef enum {
51
- StrictMode = 's',
52
- ObjectMode = 'o',
53
- NullMode = 'n',
54
- CompatMode = 'c',
55
- RailsMode = 'r',
56
- CustomMode = 'C',
57
- WabMode = 'w',
45
+ StrictMode = 's',
46
+ ObjectMode = 'o',
47
+ NullMode = 'n',
48
+ CompatMode = 'c',
49
+ RailsMode = 'r',
50
+ CustomMode = 'C',
51
+ WabMode = 'w',
58
52
  } Mode;
59
53
 
60
- typedef enum {
61
- UnixTime = 'u',
62
- UnixZTime = 'z',
63
- XmlTime = 'x',
64
- RubyTime = 'r'
65
- } TimeFormat;
54
+ typedef enum { UnixTime = 'u', UnixZTime = 'z', XmlTime = 'x', RubyTime = 'r' } TimeFormat;
66
55
 
67
56
  typedef enum {
68
- NLEsc = 'n',
69
- JSONEsc = 'j',
70
- XSSEsc = 'x',
71
- ASCIIEsc = 'a',
72
- JXEsc = 'g', // json gem
73
- RailsXEsc = 'r', // rails xss mode
74
- RailsEsc = 'R', // rails non escape
57
+ NLEsc = 'n',
58
+ JSONEsc = 'j',
59
+ XSSEsc = 'x',
60
+ ASCIIEsc = 'a',
61
+ JXEsc = 'g', // json gem
62
+ RailsXEsc = 'r', // rails xss mode
63
+ RailsEsc = 'R', // rails non escape
75
64
  } Encoding;
76
65
 
77
66
  typedef enum {
78
- BigDec = 'b',
79
- FloatDec = 'f',
80
- AutoDec = 'a'
67
+ BigDec = 'b',
68
+ FloatDec = 'f',
69
+ AutoDec = 'a',
70
+ FastDec = 'F',
71
+ RubyDec = 'r',
81
72
  } BigLoad;
82
73
 
83
74
  typedef enum {
84
- ArrayNew = 'A',
85
- ArrayType = 'a',
86
- ObjectNew = 'O',
87
- ObjectType = 'o',
75
+ ArrayNew = 'A',
76
+ ArrayType = 'a',
77
+ ObjectNew = 'O',
78
+ ObjectType = 'o',
88
79
  } DumpType;
89
80
 
90
81
  typedef enum {
91
- AutoNan = 'a',
92
- NullNan = 'n',
93
- HugeNan = 'h',
94
- WordNan = 'w',
95
- RaiseNan = 'r',
82
+ AutoNan = 'a',
83
+ NullNan = 'n',
84
+ HugeNan = 'h',
85
+ WordNan = 'w',
86
+ RaiseNan = 'r',
96
87
  } NanDump;
97
88
 
98
89
  typedef enum {
99
- STRING_IO = 'c',
100
- STREAM_IO = 's',
101
- FILE_IO = 'f',
90
+ STRING_IO = 'c',
91
+ STREAM_IO = 's',
92
+ FILE_IO = 'f',
102
93
  } StreamWriterType;
103
94
 
104
95
  typedef enum {
105
- CALLER_DUMP = 'd',
106
- CALLER_TO_JSON = 't',
107
- CALLER_GENERATE = 'g',
96
+ CALLER_DUMP = 'd',
97
+ CALLER_TO_JSON = 't',
98
+ CALLER_GENERATE = 'g',
108
99
  // Add the fast versions if necessary. Maybe unparse as well if needed.
109
100
  } DumpCaller;
110
101
 
111
102
  typedef struct _dumpOpts {
112
- bool use;
113
- char indent_str[16];
114
- char before_sep[16];
115
- char after_sep[16];
116
- char hash_nl[16];
117
- char array_nl[16];
118
- uint8_t indent_size;
119
- uint8_t before_size;
120
- uint8_t after_size;
121
- uint8_t hash_size;
122
- uint8_t array_size;
123
- char nan_dump; // NanDump
124
- bool omit_nil;
125
- int max_depth;
126
- } *DumpOpts;
103
+ bool use;
104
+ char indent_str[16];
105
+ char before_sep[16];
106
+ char after_sep[16];
107
+ char hash_nl[16];
108
+ char array_nl[16];
109
+ uint8_t indent_size;
110
+ uint8_t before_size;
111
+ uint8_t after_size;
112
+ uint8_t hash_size;
113
+ uint8_t array_size;
114
+ char nan_dump; // NanDump
115
+ bool omit_nil;
116
+ int max_depth;
117
+ } * DumpOpts;
127
118
 
128
119
  typedef struct _options {
129
- int indent; // indention for dump, default 2
130
- char circular; // YesNo
131
- char auto_define; // YesNo
132
- char sym_key; // YesNo
133
- char escape_mode; // Escape_Mode
134
- char mode; // Mode
135
- char class_cache; // YesNo
136
- char time_format; // TimeFormat
137
- char bigdec_as_num; // YesNo
138
- char bigdec_load; // BigLoad
139
- char to_hash; // YesNo
140
- char to_json; // YesNo
141
- char as_json; // YesNo
142
- char raw_json; // YesNo
143
- char nilnil; // YesNo
144
- char empty_string; // YesNo
145
- char allow_gc; // allow GC during parse
146
- char quirks_mode; // allow single JSON values instead of documents
147
- char allow_invalid; // YesNo - allow invalid unicode
148
- char create_ok; // YesNo allow create_id
149
- char allow_nan; // YEsyNo for parsing only
150
- char trace; // YesNo
151
- char safe; // YesNo
152
- char sec_prec_set; // boolean (0 or 1)
153
- char ignore_under; // YesNo - ignore attrs starting with _ if true in object and custom modes
154
- int64_t int_range_min; // dump numbers below as string
155
- int64_t int_range_max; // dump numbers above as string
156
- const char *create_id; // 0 or string
157
- size_t create_id_len; // length of create_id
158
- int sec_prec; // second precision when dumping time
159
- char float_prec; // float precision, linked to float_fmt
160
- char float_fmt[7]; // float format for dumping, if empty use Ruby
161
- VALUE hash_class; // class to use in place of Hash on load
162
- VALUE array_class; // class to use in place of Array on load
163
- struct _dumpOpts dump_opts;
164
- struct _rxClass str_rx;
165
- VALUE *ignore; // Qnil terminated array of classes or NULL
166
- } *Options;
120
+ int indent; // indention for dump, default 2
121
+ char circular; // YesNo
122
+ char auto_define; // YesNo
123
+ char sym_key; // YesNo
124
+ char escape_mode; // Escape_Mode
125
+ char mode; // Mode
126
+ char class_cache; // YesNo
127
+ char time_format; // TimeFormat
128
+ char bigdec_as_num; // YesNo
129
+ char bigdec_load; // BigLoad
130
+ char compat_bigdec; // boolean (0 or 1)
131
+ char to_hash; // YesNo
132
+ char to_json; // YesNo
133
+ char as_json; // YesNo
134
+ char raw_json; // YesNo
135
+ char nilnil; // YesNo
136
+ char empty_string; // YesNo
137
+ char allow_gc; // allow GC during parse
138
+ char quirks_mode; // allow single JSON values instead of documents
139
+ char allow_invalid; // YesNo - allow invalid unicode
140
+ char create_ok; // YesNo allow create_id
141
+ char allow_nan; // YEsyNo for parsing only
142
+ char trace; // YesNo
143
+ char safe; // YesNo
144
+ char sec_prec_set; // boolean (0 or 1)
145
+ char ignore_under; // YesNo - ignore attrs starting with _ if true in object and custom modes
146
+ char cache_keys; // YexNo
147
+ char cache_str; // string short than or equal to this are cache
148
+ int64_t int_range_min; // dump numbers below as string
149
+ int64_t int_range_max; // dump numbers above as string
150
+ const char * create_id; // 0 or string
151
+ size_t create_id_len; // length of create_id
152
+ int sec_prec; // second precision when dumping time
153
+ char float_prec; // float precision, linked to float_fmt
154
+ char float_fmt[7]; // float format for dumping, if empty use Ruby
155
+ VALUE hash_class; // class to use in place of Hash on load
156
+ VALUE array_class; // class to use in place of Array on load
157
+ struct _dumpOpts dump_opts;
158
+ struct _rxClass str_rx;
159
+ VALUE * ignore; // Qnil terminated array of classes or NULL
160
+ } * Options;
167
161
 
168
162
  struct _out;
169
- typedef void (*DumpFunc)(VALUE obj, int depth, struct _out *out, bool as_ok);
163
+ typedef void (*DumpFunc)(VALUE obj, int depth, struct _out *out, bool as_ok);
170
164
 
171
165
  // rails optimize
172
166
  typedef struct _rOpt {
173
- VALUE clas;
174
- bool on;
175
- DumpFunc dump;
176
- } *ROpt;
167
+ VALUE clas;
168
+ bool on;
169
+ DumpFunc dump;
170
+ } * ROpt;
177
171
 
178
172
  typedef struct _rOptTable {
179
- int len;
180
- int alen;
181
- ROpt table;
182
- } *ROptTable;
173
+ int len;
174
+ int alen;
175
+ ROpt table;
176
+ } * ROptTable;
183
177
 
184
178
  typedef struct _out {
185
- char *buf;
186
- char *end;
187
- char *cur;
188
- Cache8 circ_cache;
189
- slot_t circ_cnt;
190
- int indent;
191
- int depth; // used by dump_hash
192
- Options opts;
193
- uint32_t hash_cnt;
194
- bool allocated;
195
- bool omit_nil;
196
- int argc;
197
- VALUE *argv;
198
- DumpCaller caller; // used for the mimic json only
199
- ROptTable ropts;
200
- } *Out;
179
+ char * buf;
180
+ char * end;
181
+ char * cur;
182
+ Cache8 circ_cache;
183
+ slot_t circ_cnt;
184
+ int indent;
185
+ int depth; // used by dump_hash
186
+ Options opts;
187
+ uint32_t hash_cnt;
188
+ bool allocated;
189
+ bool omit_nil;
190
+ int argc;
191
+ VALUE * argv;
192
+ DumpCaller caller; // used for the mimic json only
193
+ ROptTable ropts;
194
+ } * Out;
201
195
 
202
196
  typedef struct _strWriter {
203
- struct _out out;
204
- struct _options opts;
205
- int depth;
206
- char *types; // DumpType
207
- char *types_end;
208
- int keyWritten;
197
+ struct _out out;
198
+ struct _options opts;
199
+ int depth;
200
+ char * types; // DumpType
201
+ char * types_end;
202
+ int keyWritten;
209
203
 
210
- } *StrWriter;
204
+ } * StrWriter;
211
205
 
212
206
  typedef struct _streamWriter {
213
- struct _strWriter sw;
214
- StreamWriterType type;
215
- VALUE stream;
216
- int fd;
217
- int flush_limit; // indicator of when to flush
218
- } *StreamWriter;
219
-
220
- enum {
221
- NO_VAL = 0x00,
222
- STR_VAL = 0x01,
223
- COL_VAL = 0x02,
224
- RUBY_VAL = 0x03
225
- };
207
+ struct _strWriter sw;
208
+ StreamWriterType type;
209
+ VALUE stream;
210
+ int fd;
211
+ int flush_limit; // indicator of when to flush
212
+ } * StreamWriter;
213
+
214
+ enum { NO_VAL = 0x00, STR_VAL = 0x01, COL_VAL = 0x02, RUBY_VAL = 0x03 };
226
215
 
227
216
  typedef struct _leaf {
228
- struct _leaf *next;
217
+ struct _leaf *next;
229
218
  union {
230
- const char *key; // hash key
231
- size_t index; // array index, 0 is not set
219
+ const char *key; // hash key
220
+ size_t index; // array index, 0 is not set
232
221
  };
233
222
  union {
234
- char *str; // pointer to location in json string or allocated
235
- struct _leaf *elements; // array and hash elements
236
- VALUE value;
223
+ char * str; // pointer to location in json string or allocated
224
+ struct _leaf *elements; // array and hash elements
225
+ VALUE value;
237
226
  };
238
- uint8_t rtype;
239
- uint8_t parent_type;
240
- uint8_t value_type;
241
- } *Leaf;
242
-
243
- extern VALUE oj_saj_parse(int argc, VALUE *argv, VALUE self);
244
- extern VALUE oj_sc_parse(int argc, VALUE *argv, VALUE self);
245
-
246
- extern VALUE oj_strict_parse(int argc, VALUE *argv, VALUE self);
247
- extern VALUE oj_strict_sparse(int argc, VALUE *argv, VALUE self);
248
- extern VALUE oj_compat_parse(int argc, VALUE *argv, VALUE self);
249
- extern VALUE oj_compat_load(int argc, VALUE *argv, VALUE self);
250
- extern VALUE oj_object_parse(int argc, VALUE *argv, VALUE self);
251
- extern VALUE oj_custom_parse(int argc, VALUE *argv, VALUE self);
252
- extern VALUE oj_wab_parse(int argc, VALUE *argv, VALUE self);
253
-
254
- extern VALUE oj_strict_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
255
- extern VALUE oj_compat_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
256
- extern VALUE oj_object_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
257
- extern VALUE oj_custom_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
258
-
259
- extern void oj_parse_options(VALUE ropts, Options copts);
260
-
261
- extern void oj_dump_obj_to_json(VALUE obj, Options copts, Out out);
262
- extern void oj_dump_obj_to_json_using_params(VALUE obj, Options copts, Out out, int argc, VALUE *argv);
263
- extern void oj_write_obj_to_file(VALUE obj, const char *path, Options copts);
264
- extern void oj_write_obj_to_stream(VALUE obj, VALUE stream, Options copts);
265
- extern void oj_dump_leaf_to_json(Leaf leaf, Options copts, Out out);
266
- extern void oj_write_leaf_to_file(Leaf leaf, const char *path, Options copts);
267
-
268
- extern void oj_str_writer_push_key(StrWriter sw, const char *key);
269
- extern void oj_str_writer_push_object(StrWriter sw, const char *key);
270
- extern void oj_str_writer_push_array(StrWriter sw, const char *key);
271
- extern void oj_str_writer_push_value(StrWriter sw, VALUE val, const char *key);
272
- extern void oj_str_writer_push_json(StrWriter sw, const char *json, const char *key);
273
- extern void oj_str_writer_pop(StrWriter sw);
274
- extern void oj_str_writer_pop_all(StrWriter sw);
275
-
276
- extern void oj_init_doc(void);
277
- extern void oj_string_writer_init();
278
- extern void oj_stream_writer_init();
279
- extern void oj_str_writer_init(StrWriter sw, int buf_size);
280
- extern VALUE oj_define_mimic_json(int argc, VALUE *argv, VALUE self);
281
- extern VALUE oj_mimic_generate(int argc, VALUE *argv, VALUE self);
282
- extern VALUE oj_mimic_pretty_generate(int argc, VALUE *argv, VALUE self);
283
- extern void oj_parse_mimic_dump_options(VALUE ropts, Options copts);
284
-
285
- extern VALUE oj_mimic_parse(int argc, VALUE *argv, VALUE self);
286
- extern VALUE oj_get_json_err_class(const char *err_classname);
287
- extern void oj_parse_opt_match_string(RxClass rc, VALUE ropts);
288
-
289
- extern VALUE oj_rails_encode(int argc, VALUE *argv, VALUE self);
290
-
291
- extern VALUE Oj;
292
- extern struct _options oj_default_options;
293
- extern rb_encoding *oj_utf8_encoding;
294
-
295
- extern VALUE oj_bag_class;
296
- extern VALUE oj_bigdecimal_class;
297
- extern VALUE oj_cstack_class;
298
- extern VALUE oj_date_class;
299
- extern VALUE oj_datetime_class;
300
- extern VALUE oj_doc_class;
301
- extern VALUE oj_enumerable_class;
302
- extern VALUE oj_json_generator_error_class;
303
- extern VALUE oj_json_parser_error_class;
304
- extern VALUE oj_stream_writer_class;
305
- extern VALUE oj_string_writer_class;
306
- extern VALUE oj_stringio_class;
307
- extern VALUE oj_struct_class;
308
-
309
- extern VALUE oj_allow_nan_sym;
310
- extern VALUE oj_array_class_sym;
311
- extern VALUE oj_array_nl_sym;
312
- extern VALUE oj_ascii_only_sym;
313
- extern VALUE oj_create_additions_sym;
314
- extern VALUE oj_hash_class_sym;
315
- extern VALUE oj_indent_sym;
316
- extern VALUE oj_max_nesting_sym;
317
- extern VALUE oj_object_class_sym;
318
- extern VALUE oj_object_nl_sym;
319
- extern VALUE oj_quirks_mode_sym;
320
- extern VALUE oj_space_before_sym;
321
- extern VALUE oj_space_sym;
322
- extern VALUE oj_trace_sym;
323
-
324
- extern VALUE oj_slash_string;
325
-
326
- extern ID oj_add_value_id;
327
- extern ID oj_array_append_id;
328
- extern ID oj_array_end_id;
329
- extern ID oj_array_start_id;
330
- extern ID oj_as_json_id;
331
- extern ID oj_begin_id;
332
- extern ID oj_bigdecimal_id;
333
- extern ID oj_end_id;
334
- extern ID oj_error_id;
335
- extern ID oj_exclude_end_id;
336
- extern ID oj_file_id;
337
- extern ID oj_fileno_id;
338
- extern ID oj_ftype_id;
339
- extern ID oj_has_key_id;
340
- extern ID oj_hash_end_id;
341
- extern ID oj_hash_key_id;
342
- extern ID oj_hash_set_id;
343
- extern ID oj_hash_start_id;
344
- extern ID oj_iconv_id;
345
- extern ID oj_instance_variables_id;
346
- extern ID oj_json_create_id;
347
- extern ID oj_length_id;
348
- extern ID oj_new_id;
349
- extern ID oj_parse_id;
350
- extern ID oj_pos_id;
351
- extern ID oj_read_id;
352
- extern ID oj_readpartial_id;
353
- extern ID oj_replace_id;
354
- extern ID oj_stat_id;
355
- extern ID oj_string_id;
356
- extern ID oj_raw_json_id;
357
- extern ID oj_to_h_id;
358
- extern ID oj_to_hash_id;
359
- extern ID oj_to_json_id;
360
- extern ID oj_to_s_id;
361
- extern ID oj_to_sym_id;
362
- extern ID oj_to_time_id;
363
- extern ID oj_tv_nsec_id;
364
- extern ID oj_tv_sec_id;
365
- extern ID oj_tv_usec_id;
366
- extern ID oj_utc_id;
367
- extern ID oj_utc_offset_id;
368
- extern ID oj_utcq_id;
369
- extern ID oj_write_id;
370
-
371
- extern bool oj_use_hash_alt;
372
- extern bool oj_use_array_alt;
373
- extern bool string_writer_optimized;
227
+ uint8_t rtype;
228
+ uint8_t parent_type;
229
+ uint8_t value_type;
230
+ } * Leaf;
231
+
232
+ extern VALUE oj_saj_parse(int argc, VALUE *argv, VALUE self);
233
+ extern VALUE oj_sc_parse(int argc, VALUE *argv, VALUE self);
234
+
235
+ extern VALUE oj_strict_parse(int argc, VALUE *argv, VALUE self);
236
+ extern VALUE oj_strict_sparse(int argc, VALUE *argv, VALUE self);
237
+ extern VALUE oj_compat_parse(int argc, VALUE *argv, VALUE self);
238
+ extern VALUE oj_compat_load(int argc, VALUE *argv, VALUE self);
239
+ extern VALUE oj_object_parse(int argc, VALUE *argv, VALUE self);
240
+ extern VALUE oj_custom_parse(int argc, VALUE *argv, VALUE self);
241
+ extern VALUE oj_wab_parse(int argc, VALUE *argv, VALUE self);
242
+
243
+ extern VALUE oj_strict_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
244
+ extern VALUE oj_compat_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
245
+ extern VALUE oj_object_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
246
+ extern VALUE oj_custom_parse_cstr(int argc, VALUE *argv, char *json, size_t len);
247
+
248
+ extern void oj_parse_options(VALUE ropts, Options copts);
249
+
250
+ extern void oj_dump_obj_to_json(VALUE obj, Options copts, Out out);
251
+ extern void
252
+ oj_dump_obj_to_json_using_params(VALUE obj, Options copts, Out out, int argc, VALUE *argv);
253
+ extern void oj_write_obj_to_file(VALUE obj, const char *path, Options copts);
254
+ extern void oj_write_obj_to_stream(VALUE obj, VALUE stream, Options copts);
255
+ extern void oj_dump_leaf_to_json(Leaf leaf, Options copts, Out out);
256
+ extern void oj_write_leaf_to_file(Leaf leaf, const char *path, Options copts);
257
+
258
+ extern void oj_str_writer_push_key(StrWriter sw, const char *key);
259
+ extern void oj_str_writer_push_object(StrWriter sw, const char *key);
260
+ extern void oj_str_writer_push_array(StrWriter sw, const char *key);
261
+ extern void oj_str_writer_push_value(StrWriter sw, VALUE val, const char *key);
262
+ extern void oj_str_writer_push_json(StrWriter sw, const char *json, const char *key);
263
+ extern void oj_str_writer_pop(StrWriter sw);
264
+ extern void oj_str_writer_pop_all(StrWriter sw);
265
+
266
+ extern void oj_init_doc(void);
267
+ extern void oj_string_writer_init();
268
+ extern void oj_stream_writer_init();
269
+ extern void oj_str_writer_init(StrWriter sw, int buf_size);
270
+ extern VALUE oj_define_mimic_json(int argc, VALUE *argv, VALUE self);
271
+ extern VALUE oj_mimic_generate(int argc, VALUE *argv, VALUE self);
272
+ extern VALUE oj_mimic_pretty_generate(int argc, VALUE *argv, VALUE self);
273
+ extern void oj_parse_mimic_dump_options(VALUE ropts, Options copts);
274
+
275
+ extern VALUE oj_mimic_parse(int argc, VALUE *argv, VALUE self);
276
+ extern VALUE oj_get_json_err_class(const char *err_classname);
277
+ extern void oj_parse_opt_match_string(RxClass rc, VALUE ropts);
278
+
279
+ extern VALUE oj_rails_encode(int argc, VALUE *argv, VALUE self);
280
+
281
+ extern VALUE Oj;
282
+ extern struct _options oj_default_options;
283
+ extern rb_encoding * oj_utf8_encoding;
284
+
285
+ extern VALUE oj_bag_class;
286
+ extern VALUE oj_bigdecimal_class;
287
+ extern VALUE oj_cstack_class;
288
+ extern VALUE oj_date_class;
289
+ extern VALUE oj_datetime_class;
290
+ extern VALUE oj_doc_class;
291
+ extern VALUE oj_enumerable_class;
292
+ extern VALUE oj_json_generator_error_class;
293
+ extern VALUE oj_json_parser_error_class;
294
+ extern VALUE oj_stream_writer_class;
295
+ extern VALUE oj_string_writer_class;
296
+ extern VALUE oj_stringio_class;
297
+ extern VALUE oj_struct_class;
298
+
299
+ extern VALUE oj_allow_nan_sym;
300
+ extern VALUE oj_array_class_sym;
301
+ extern VALUE oj_array_nl_sym;
302
+ extern VALUE oj_ascii_only_sym;
303
+ extern VALUE oj_create_additions_sym;
304
+ extern VALUE oj_decimal_class_sym;
305
+ extern VALUE oj_hash_class_sym;
306
+ extern VALUE oj_indent_sym;
307
+ extern VALUE oj_max_nesting_sym;
308
+ extern VALUE oj_object_class_sym;
309
+ extern VALUE oj_object_nl_sym;
310
+ extern VALUE oj_quirks_mode_sym;
311
+ extern VALUE oj_space_before_sym;
312
+ extern VALUE oj_space_sym;
313
+ extern VALUE oj_trace_sym;
314
+
315
+ extern VALUE oj_slash_string;
316
+
317
+ extern ID oj_add_value_id;
318
+ extern ID oj_array_append_id;
319
+ extern ID oj_array_end_id;
320
+ extern ID oj_array_start_id;
321
+ extern ID oj_as_json_id;
322
+ extern ID oj_begin_id;
323
+ extern ID oj_bigdecimal_id;
324
+ extern ID oj_end_id;
325
+ extern ID oj_error_id;
326
+ extern ID oj_exclude_end_id;
327
+ extern ID oj_file_id;
328
+ extern ID oj_fileno_id;
329
+ extern ID oj_ftype_id;
330
+ extern ID oj_has_key_id;
331
+ extern ID oj_hash_end_id;
332
+ extern ID oj_hash_key_id;
333
+ extern ID oj_hash_set_id;
334
+ extern ID oj_hash_start_id;
335
+ extern ID oj_iconv_id;
336
+ extern ID oj_instance_variables_id;
337
+ extern ID oj_json_create_id;
338
+ extern ID oj_length_id;
339
+ extern ID oj_new_id;
340
+ extern ID oj_parse_id;
341
+ extern ID oj_pos_id;
342
+ extern ID oj_read_id;
343
+ extern ID oj_readpartial_id;
344
+ extern ID oj_replace_id;
345
+ extern ID oj_stat_id;
346
+ extern ID oj_string_id;
347
+ extern ID oj_raw_json_id;
348
+ extern ID oj_to_h_id;
349
+ extern ID oj_to_hash_id;
350
+ extern ID oj_to_json_id;
351
+ extern ID oj_to_s_id;
352
+ extern ID oj_to_sym_id;
353
+ extern ID oj_to_time_id;
354
+ extern ID oj_tv_nsec_id;
355
+ extern ID oj_tv_sec_id;
356
+ extern ID oj_tv_usec_id;
357
+ extern ID oj_utc_id;
358
+ extern ID oj_utc_offset_id;
359
+ extern ID oj_utcq_id;
360
+ extern ID oj_write_id;
361
+
362
+ extern bool oj_use_hash_alt;
363
+ extern bool oj_use_array_alt;
364
+ extern bool string_writer_optimized;
374
365
 
375
366
  #ifdef HAVE_PTHREAD_MUTEX_INIT
376
- extern pthread_mutex_t oj_cache_mutex;
367
+ extern pthread_mutex_t oj_cache_mutex;
377
368
  #else
378
- extern VALUE oj_cache_mutex;
369
+ extern VALUE oj_cache_mutex;
379
370
  #endif
380
371
 
381
372
  #if defined(cplusplus)
382
373
  #if 0
383
374
  { /* satisfy cc-mode */
384
375
  #endif
385
- } /* extern "C" { */
376
+ } /* extern "C" { */
386
377
  #endif
387
378
  #endif /* OJ_H */