oj 3.11.5 → 3.16.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1421 -0
- data/README.md +19 -5
- data/RELEASE_NOTES.md +61 -0
- data/ext/oj/buf.h +20 -6
- data/ext/oj/cache.c +329 -0
- data/ext/oj/cache.h +22 -0
- data/ext/oj/cache8.c +10 -9
- data/ext/oj/circarray.c +8 -6
- data/ext/oj/circarray.h +2 -2
- data/ext/oj/code.c +19 -33
- data/ext/oj/code.h +2 -2
- data/ext/oj/compat.c +27 -77
- data/ext/oj/custom.c +86 -179
- data/ext/oj/debug.c +126 -0
- data/ext/oj/dump.c +256 -249
- data/ext/oj/dump.h +26 -12
- data/ext/oj/dump_compat.c +565 -642
- data/ext/oj/dump_leaf.c +17 -63
- data/ext/oj/dump_object.c +65 -187
- data/ext/oj/dump_strict.c +27 -51
- data/ext/oj/encoder.c +43 -0
- data/ext/oj/err.c +2 -13
- data/ext/oj/err.h +24 -8
- data/ext/oj/extconf.rb +21 -6
- data/ext/oj/fast.c +149 -149
- data/ext/oj/intern.c +313 -0
- data/ext/oj/intern.h +22 -0
- data/ext/oj/mem.c +318 -0
- data/ext/oj/mem.h +53 -0
- data/ext/oj/mimic_json.c +121 -106
- data/ext/oj/object.c +85 -162
- data/ext/oj/odd.c +89 -67
- data/ext/oj/odd.h +15 -15
- data/ext/oj/oj.c +542 -411
- data/ext/oj/oj.h +99 -73
- data/ext/oj/parse.c +175 -187
- data/ext/oj/parse.h +26 -24
- data/ext/oj/parser.c +1600 -0
- data/ext/oj/parser.h +101 -0
- data/ext/oj/rails.c +112 -159
- data/ext/oj/rails.h +1 -1
- data/ext/oj/reader.c +11 -14
- data/ext/oj/reader.h +4 -2
- data/ext/oj/resolve.c +5 -24
- data/ext/oj/rxclass.c +7 -6
- data/ext/oj/rxclass.h +1 -1
- data/ext/oj/saj.c +22 -33
- data/ext/oj/saj2.c +584 -0
- data/ext/oj/saj2.h +23 -0
- data/ext/oj/scp.c +5 -28
- data/ext/oj/sparse.c +28 -72
- data/ext/oj/stream_writer.c +50 -40
- data/ext/oj/strict.c +56 -61
- data/ext/oj/string_writer.c +72 -39
- data/ext/oj/trace.h +31 -4
- data/ext/oj/usual.c +1218 -0
- data/ext/oj/usual.h +69 -0
- data/ext/oj/util.h +1 -1
- data/ext/oj/val_stack.c +14 -3
- data/ext/oj/val_stack.h +8 -7
- data/ext/oj/validate.c +46 -0
- data/ext/oj/wab.c +63 -88
- data/lib/oj/active_support_helper.rb +1 -3
- data/lib/oj/bag.rb +7 -1
- data/lib/oj/easy_hash.rb +4 -5
- data/lib/oj/error.rb +1 -2
- data/lib/oj/json.rb +162 -150
- data/lib/oj/mimic.rb +9 -7
- data/lib/oj/saj.rb +20 -6
- data/lib/oj/schandler.rb +5 -4
- data/lib/oj/state.rb +12 -8
- data/lib/oj/version.rb +1 -2
- data/lib/oj.rb +2 -0
- data/pages/Compatibility.md +1 -1
- data/pages/InstallOptions.md +20 -0
- data/pages/JsonGem.md +15 -0
- data/pages/Modes.md +8 -3
- data/pages/Options.md +43 -5
- data/pages/Parser.md +309 -0
- data/pages/Rails.md +14 -2
- data/test/_test_active.rb +8 -9
- data/test/_test_active_mimic.rb +7 -8
- data/test/_test_mimic_rails.rb +17 -20
- data/test/activerecord/result_test.rb +5 -6
- data/test/activesupport6/encoding_test.rb +63 -28
- data/test/{activesupport5 → activesupport7}/abstract_unit.rb +16 -12
- data/test/{activesupport5 → activesupport7}/decoding_test.rb +2 -10
- data/test/{activesupport5 → activesupport7}/encoding_test.rb +86 -50
- data/test/{activesupport5 → activesupport7}/encoding_test_cases.rb +6 -0
- data/test/{activesupport5 → activesupport7}/time_zone_test_helpers.rb +8 -0
- data/test/files.rb +15 -15
- data/test/foo.rb +16 -45
- data/test/helper.rb +11 -8
- data/test/isolated/shared.rb +3 -2
- data/test/json_gem/json_addition_test.rb +2 -2
- data/test/json_gem/json_common_interface_test.rb +8 -6
- data/test/json_gem/json_encoding_test.rb +0 -0
- data/test/json_gem/json_ext_parser_test.rb +1 -0
- data/test/json_gem/json_fixtures_test.rb +3 -2
- data/test/json_gem/json_generator_test.rb +56 -38
- data/test/json_gem/json_generic_object_test.rb +11 -11
- data/test/json_gem/json_parser_test.rb +54 -47
- data/test/json_gem/json_string_matching_test.rb +9 -9
- data/test/json_gem/test_helper.rb +7 -3
- data/test/mem.rb +34 -0
- data/test/perf.rb +22 -27
- data/test/perf_compat.rb +31 -33
- data/test/perf_dump.rb +50 -0
- data/test/perf_fast.rb +80 -82
- data/test/perf_file.rb +27 -29
- data/test/perf_object.rb +65 -69
- data/test/perf_once.rb +59 -0
- data/test/perf_parser.rb +183 -0
- data/test/perf_saj.rb +46 -54
- data/test/perf_scp.rb +58 -69
- data/test/perf_simple.rb +41 -39
- data/test/perf_strict.rb +74 -82
- data/test/perf_wab.rb +67 -69
- data/test/prec.rb +5 -5
- data/test/sample/change.rb +0 -1
- data/test/sample/dir.rb +0 -1
- data/test/sample/doc.rb +0 -1
- data/test/sample/file.rb +0 -1
- data/test/sample/group.rb +0 -1
- data/test/sample/hasprops.rb +0 -1
- data/test/sample/layer.rb +0 -1
- data/test/sample/rect.rb +0 -1
- data/test/sample/shape.rb +0 -1
- data/test/sample/text.rb +0 -1
- data/test/sample.rb +16 -16
- data/test/sample_json.rb +8 -8
- data/test/test_compat.rb +95 -43
- data/test/test_custom.rb +73 -51
- data/test/test_debian.rb +7 -10
- data/test/test_fast.rb +135 -79
- data/test/test_file.rb +41 -30
- data/test/test_gc.rb +16 -5
- data/test/test_generate.rb +5 -5
- data/test/test_hash.rb +5 -5
- data/test/test_integer_range.rb +9 -9
- data/test/test_null.rb +20 -20
- data/test/test_object.rb +99 -96
- data/test/test_parser.rb +11 -0
- data/test/test_parser_debug.rb +27 -0
- data/test/test_parser_saj.rb +337 -0
- data/test/test_parser_usual.rb +251 -0
- data/test/test_rails.rb +2 -2
- data/test/test_saj.rb +10 -8
- data/test/test_scp.rb +37 -39
- data/test/test_strict.rb +40 -32
- data/test/test_various.rb +165 -84
- data/test/test_wab.rb +48 -44
- data/test/test_writer.rb +47 -47
- data/test/tests.rb +13 -5
- data/test/tests_mimic.rb +12 -3
- data/test/tests_mimic_addition.rb +12 -3
- metadata +74 -128
- data/ext/oj/hash.c +0 -131
- data/ext/oj/hash.h +0 -19
- data/ext/oj/hash_test.c +0 -491
- data/test/activesupport4/decoding_test.rb +0 -108
- data/test/activesupport4/encoding_test.rb +0 -531
- data/test/activesupport4/test_helper.rb +0 -41
- data/test/activesupport5/test_helper.rb +0 -72
- data/test/bar.rb +0 -35
- data/test/baz.rb +0 -16
- data/test/zoo.rb +0 -13
data/ext/oj/string_writer.c
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
#include "dump.h"
|
5
5
|
#include "encode.h"
|
6
|
+
#include "mem.h"
|
6
7
|
|
7
8
|
extern VALUE Oj;
|
8
9
|
|
@@ -20,7 +21,7 @@ static void push_type(StrWriter sw, DumpType type) {
|
|
20
21
|
if (sw->types_end <= sw->types + sw->depth + 1) {
|
21
22
|
size_t size = (sw->types_end - sw->types) * 2;
|
22
23
|
|
23
|
-
|
24
|
+
OJ_R_REALLOC_N(sw->types, char, size);
|
24
25
|
sw->types_end = sw->types + size;
|
25
26
|
}
|
26
27
|
sw->depth++;
|
@@ -43,7 +44,7 @@ static void maybe_comma(StrWriter sw) {
|
|
43
44
|
void oj_str_writer_init(StrWriter sw, int buf_size) {
|
44
45
|
sw->opts = oj_default_options;
|
45
46
|
sw->depth = 0;
|
46
|
-
sw->types =
|
47
|
+
sw->types = OJ_R_ALLOC_N(char, 256);
|
47
48
|
sw->types_end = sw->types + 256;
|
48
49
|
*sw->types = '\0';
|
49
50
|
sw->keyWritten = 0;
|
@@ -53,10 +54,13 @@ void oj_str_writer_init(StrWriter sw, int buf_size) {
|
|
53
54
|
} else if (buf_size < 1024) {
|
54
55
|
buf_size = 1024;
|
55
56
|
}
|
56
|
-
|
57
|
-
|
58
|
-
sw->out.
|
59
|
-
sw->out.cur
|
57
|
+
// Must be allocated. Using the out.stack_buffer results in double frees
|
58
|
+
// and I haven't figured out why yet.
|
59
|
+
sw->out.buf = OJ_R_ALLOC_N(char, buf_size);
|
60
|
+
sw->out.cur = sw->out.buf;
|
61
|
+
sw->out.end = sw->out.buf + buf_size - BUFFER_EXTRA;
|
62
|
+
sw->out.allocated = true;
|
63
|
+
|
60
64
|
*sw->out.cur = '\0';
|
61
65
|
sw->out.circ_cache = NULL;
|
62
66
|
sw->out.circ_cnt = 0;
|
@@ -66,7 +70,6 @@ void oj_str_writer_init(StrWriter sw, int buf_size) {
|
|
66
70
|
sw->out.depth = 0;
|
67
71
|
sw->out.argc = 0;
|
68
72
|
sw->out.argv = NULL;
|
69
|
-
sw->out.caller = 0;
|
70
73
|
sw->out.ropts = NULL;
|
71
74
|
sw->out.omit_nil = oj_default_options.dump_opts.omit_nil;
|
72
75
|
}
|
@@ -222,16 +225,35 @@ void oj_str_writer_pop_all(StrWriter sw) {
|
|
222
225
|
}
|
223
226
|
}
|
224
227
|
|
225
|
-
static void
|
228
|
+
static void string_writer_free(void *ptr) {
|
226
229
|
StrWriter sw;
|
227
230
|
|
228
231
|
if (0 == ptr) {
|
229
232
|
return;
|
230
233
|
}
|
231
234
|
sw = (StrWriter)ptr;
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
+
|
236
|
+
oj_out_free(&sw->out);
|
237
|
+
|
238
|
+
OJ_R_FREE(sw->types);
|
239
|
+
OJ_R_FREE(ptr);
|
240
|
+
}
|
241
|
+
|
242
|
+
static const rb_data_type_t oj_string_writer_type = {
|
243
|
+
"Oj/string_writer",
|
244
|
+
{
|
245
|
+
NULL,
|
246
|
+
string_writer_free,
|
247
|
+
NULL,
|
248
|
+
},
|
249
|
+
0,
|
250
|
+
0,
|
251
|
+
};
|
252
|
+
|
253
|
+
StrWriter oj_str_writer_unwrap(VALUE writer) {
|
254
|
+
StrWriter sw;
|
255
|
+
TypedData_Get_Struct(writer, struct _strWriter, &oj_string_writer_type, sw);
|
256
|
+
return sw;
|
235
257
|
}
|
236
258
|
|
237
259
|
/* Document-method: new
|
@@ -248,10 +270,10 @@ static void str_writer_free(void *ptr) {
|
|
248
270
|
* should be.
|
249
271
|
*
|
250
272
|
* - *io* [_IO_] stream to write to
|
251
|
-
* - *options* [_Hash_]
|
273
|
+
* - *options* [_Hash_] formatting options
|
252
274
|
*/
|
253
275
|
static VALUE str_writer_new(int argc, VALUE *argv, VALUE self) {
|
254
|
-
StrWriter sw =
|
276
|
+
StrWriter sw = OJ_R_ALLOC(struct _strWriter);
|
255
277
|
|
256
278
|
oj_str_writer_init(sw, 0);
|
257
279
|
if (1 == argc) {
|
@@ -261,7 +283,7 @@ static VALUE str_writer_new(int argc, VALUE *argv, VALUE self) {
|
|
261
283
|
sw->out.argv = argv + 1;
|
262
284
|
sw->out.indent = sw->opts.indent;
|
263
285
|
|
264
|
-
return
|
286
|
+
return TypedData_Wrap_Struct(oj_string_writer_class, &oj_string_writer_type, sw);
|
265
287
|
}
|
266
288
|
|
267
289
|
/* Document-method: push_key
|
@@ -273,9 +295,9 @@ static VALUE str_writer_new(int argc, VALUE *argv, VALUE self) {
|
|
273
295
|
* - *key* [_String_] the key pending for the next push
|
274
296
|
*/
|
275
297
|
static VALUE str_writer_push_key(VALUE self, VALUE key) {
|
276
|
-
StrWriter sw
|
298
|
+
StrWriter sw;
|
299
|
+
TypedData_Get_Struct(self, struct _strWriter, &oj_string_writer_type, sw);
|
277
300
|
|
278
|
-
rb_check_type(key, T_STRING);
|
279
301
|
oj_str_writer_push_key(sw, StringValuePtr(key));
|
280
302
|
|
281
303
|
return Qnil;
|
@@ -289,7 +311,8 @@ static VALUE str_writer_push_key(VALUE self, VALUE key) {
|
|
289
311
|
* - *key* [_String_] the key if adding to an object in the JSON document
|
290
312
|
*/
|
291
313
|
static VALUE str_writer_push_object(int argc, VALUE *argv, VALUE self) {
|
292
|
-
StrWriter sw
|
314
|
+
StrWriter sw;
|
315
|
+
TypedData_Get_Struct(self, struct _strWriter, &oj_string_writer_type, sw);
|
293
316
|
|
294
317
|
switch (argc) {
|
295
318
|
case 0: oj_str_writer_push_object(sw, 0); break;
|
@@ -297,7 +320,6 @@ static VALUE str_writer_push_object(int argc, VALUE *argv, VALUE self) {
|
|
297
320
|
if (Qnil == argv[0]) {
|
298
321
|
oj_str_writer_push_object(sw, 0);
|
299
322
|
} else {
|
300
|
-
rb_check_type(argv[0], T_STRING);
|
301
323
|
oj_str_writer_push_object(sw, StringValuePtr(argv[0]));
|
302
324
|
}
|
303
325
|
break;
|
@@ -318,7 +340,8 @@ static VALUE str_writer_push_object(int argc, VALUE *argv, VALUE self) {
|
|
318
340
|
* - *key* [_String_] the key if adding to an object in the JSON document
|
319
341
|
*/
|
320
342
|
static VALUE str_writer_push_array(int argc, VALUE *argv, VALUE self) {
|
321
|
-
StrWriter sw
|
343
|
+
StrWriter sw;
|
344
|
+
TypedData_Get_Struct(self, struct _strWriter, &oj_string_writer_type, sw);
|
322
345
|
|
323
346
|
switch (argc) {
|
324
347
|
case 0: oj_str_writer_push_array(sw, 0); break;
|
@@ -326,7 +349,6 @@ static VALUE str_writer_push_array(int argc, VALUE *argv, VALUE self) {
|
|
326
349
|
if (Qnil == argv[0]) {
|
327
350
|
oj_str_writer_push_array(sw, 0);
|
328
351
|
} else {
|
329
|
-
rb_check_type(argv[0], T_STRING);
|
330
352
|
oj_str_writer_push_array(sw, StringValuePtr(argv[0]));
|
331
353
|
}
|
332
354
|
break;
|
@@ -347,14 +369,16 @@ static VALUE str_writer_push_array(int argc, VALUE *argv, VALUE self) {
|
|
347
369
|
* - *key* [_String_] the key if adding to an object in the JSON document
|
348
370
|
*/
|
349
371
|
static VALUE str_writer_push_value(int argc, VALUE *argv, VALUE self) {
|
372
|
+
StrWriter sw;
|
373
|
+
TypedData_Get_Struct(self, struct _strWriter, &oj_string_writer_type, sw);
|
374
|
+
|
350
375
|
switch (argc) {
|
351
|
-
case 1: oj_str_writer_push_value(
|
376
|
+
case 1: oj_str_writer_push_value(sw, *argv, 0); break;
|
352
377
|
case 2:
|
353
378
|
if (Qnil == argv[1]) {
|
354
|
-
oj_str_writer_push_value(
|
379
|
+
oj_str_writer_push_value(sw, *argv, 0);
|
355
380
|
} else {
|
356
|
-
|
357
|
-
oj_str_writer_push_value((StrWriter)DATA_PTR(self), *argv, StringValuePtr(argv[1]));
|
381
|
+
oj_str_writer_push_value(sw, *argv, StringValuePtr(argv[1]));
|
358
382
|
}
|
359
383
|
break;
|
360
384
|
default: rb_raise(rb_eArgError, "Wrong number of argument to 'push_value'."); break;
|
@@ -372,17 +396,16 @@ static VALUE str_writer_push_value(int argc, VALUE *argv, VALUE self) {
|
|
372
396
|
* - *key* [_String_] the key if adding to an object in the JSON document
|
373
397
|
*/
|
374
398
|
static VALUE str_writer_push_json(int argc, VALUE *argv, VALUE self) {
|
375
|
-
|
399
|
+
StrWriter sw;
|
400
|
+
TypedData_Get_Struct(self, struct _strWriter, &oj_string_writer_type, sw);
|
401
|
+
|
376
402
|
switch (argc) {
|
377
|
-
case 1: oj_str_writer_push_json(
|
403
|
+
case 1: oj_str_writer_push_json(sw, StringValuePtr(*argv), 0); break;
|
378
404
|
case 2:
|
379
405
|
if (Qnil == argv[1]) {
|
380
|
-
oj_str_writer_push_json(
|
406
|
+
oj_str_writer_push_json(sw, StringValuePtr(*argv), 0);
|
381
407
|
} else {
|
382
|
-
|
383
|
-
oj_str_writer_push_json((StrWriter)DATA_PTR(self),
|
384
|
-
StringValuePtr(*argv),
|
385
|
-
StringValuePtr(argv[1]));
|
408
|
+
oj_str_writer_push_json(sw, StringValuePtr(*argv), StringValuePtr(argv[1]));
|
386
409
|
}
|
387
410
|
break;
|
388
411
|
default: rb_raise(rb_eArgError, "Wrong number of argument to 'push_json'."); break;
|
@@ -396,7 +419,10 @@ static VALUE str_writer_push_json(int argc, VALUE *argv, VALUE self) {
|
|
396
419
|
* currently open.
|
397
420
|
*/
|
398
421
|
static VALUE str_writer_pop(VALUE self) {
|
399
|
-
|
422
|
+
StrWriter sw;
|
423
|
+
TypedData_Get_Struct(self, struct _strWriter, &oj_string_writer_type, sw);
|
424
|
+
|
425
|
+
oj_str_writer_pop(sw);
|
400
426
|
return Qnil;
|
401
427
|
}
|
402
428
|
|
@@ -407,7 +433,10 @@ static VALUE str_writer_pop(VALUE self) {
|
|
407
433
|
* currently open.
|
408
434
|
*/
|
409
435
|
static VALUE str_writer_pop_all(VALUE self) {
|
410
|
-
|
436
|
+
StrWriter sw;
|
437
|
+
TypedData_Get_Struct(self, struct _strWriter, &oj_string_writer_type, sw);
|
438
|
+
|
439
|
+
oj_str_writer_pop_all(sw);
|
411
440
|
|
412
441
|
return Qnil;
|
413
442
|
}
|
@@ -418,7 +447,8 @@ static VALUE str_writer_pop_all(VALUE self) {
|
|
418
447
|
* Reset the writer back to the empty state.
|
419
448
|
*/
|
420
449
|
static VALUE str_writer_reset(VALUE self) {
|
421
|
-
StrWriter sw
|
450
|
+
StrWriter sw;
|
451
|
+
TypedData_Get_Struct(self, struct _strWriter, &oj_string_writer_type, sw);
|
422
452
|
|
423
453
|
sw->depth = 0;
|
424
454
|
*sw->types = '\0';
|
@@ -437,8 +467,9 @@ static VALUE str_writer_reset(VALUE self) {
|
|
437
467
|
* *return* [_String_]
|
438
468
|
*/
|
439
469
|
static VALUE str_writer_to_s(VALUE self) {
|
440
|
-
StrWriter sw
|
441
|
-
|
470
|
+
StrWriter sw;
|
471
|
+
TypedData_Get_Struct(self, struct _strWriter, &oj_string_writer_type, sw);
|
472
|
+
VALUE rstr = rb_str_new(sw->out.buf, sw->out.cur - sw->out.buf);
|
442
473
|
|
443
474
|
return oj_encode(rstr);
|
444
475
|
}
|
@@ -449,7 +480,7 @@ static VALUE str_writer_to_s(VALUE self) {
|
|
449
480
|
* Returns the contents of the writer as a JSON element. If called from inside
|
450
481
|
* an array or hash by Oj the raw buffer will be used othersize a more
|
451
482
|
* inefficient parse of the contents and a return of the result is
|
452
|
-
* completed. The parse uses the
|
483
|
+
* completed. The parse uses the strict mode.
|
453
484
|
*
|
454
485
|
* *return* [_Hash_|_Array_|_String_|_Integer_|_Float_|_True_|_False_|_nil|)
|
455
486
|
*/
|
@@ -466,11 +497,13 @@ static VALUE str_writer_as_json(VALUE self) {
|
|
466
497
|
* by pushing values into the document. Pushing an array or an object will
|
467
498
|
* create that element in the JSON document and subsequent pushes will add the
|
468
499
|
* elements to that array or object until a pop() is called. When complete
|
469
|
-
* calling to_s() will return the JSON document. Note
|
500
|
+
* calling to_s() will return the JSON document. Note that calling to_s() before
|
470
501
|
* construction is complete will return the document in it's current state.
|
471
502
|
*/
|
472
|
-
void oj_string_writer_init() {
|
503
|
+
void oj_string_writer_init(void) {
|
473
504
|
oj_string_writer_class = rb_define_class_under(Oj, "StringWriter", rb_cObject);
|
505
|
+
rb_gc_register_address(&oj_string_writer_class);
|
506
|
+
rb_undef_alloc_func(oj_string_writer_class);
|
474
507
|
rb_define_module_function(oj_string_writer_class, "new", str_writer_new, -1);
|
475
508
|
rb_define_method(oj_string_writer_class, "push_key", str_writer_push_key, 1);
|
476
509
|
rb_define_method(oj_string_writer_class, "push_object", str_writer_push_object, -1);
|
data/ext/oj/trace.h
CHANGED
@@ -17,12 +17,39 @@ typedef enum {
|
|
17
17
|
|
18
18
|
struct _parseInfo;
|
19
19
|
|
20
|
-
extern void
|
21
|
-
oj_trace(const char *func, VALUE obj, const char *file, int line, int depth, TraceWhere where);
|
20
|
+
extern void oj_trace(const char *func, VALUE obj, const char *file, int line, int depth, TraceWhere where);
|
22
21
|
extern void oj_trace_parse_in(const char *func, struct _parseInfo *pi, const char *file, int line);
|
23
|
-
extern void
|
24
|
-
oj_trace_parse_call(const char *func, struct _parseInfo *pi, const char *file, int line, VALUE obj);
|
22
|
+
extern void oj_trace_parse_call(const char *func, struct _parseInfo *pi, const char *file, int line, VALUE obj);
|
25
23
|
extern void oj_trace_parse_hash_end(struct _parseInfo *pi, const char *file, int line);
|
26
24
|
extern void oj_trace_parse_array_end(struct _parseInfo *pi, const char *file, int line);
|
27
25
|
|
26
|
+
#ifdef OJ_ENABLE_TRACE_LOG
|
27
|
+
#define TRACE(option, func, obj, depth, where) \
|
28
|
+
if (RB_UNLIKELY(Yes == option)) { \
|
29
|
+
oj_trace(func, obj, __FILE__, __LINE__, depth, where); \
|
30
|
+
}
|
31
|
+
#define TRACE_PARSE_IN(option, func, pi) \
|
32
|
+
if (RB_UNLIKELY(Yes == option)) { \
|
33
|
+
oj_trace_parse_in(func, pi, __FILE__, __LINE__); \
|
34
|
+
}
|
35
|
+
#define TRACE_PARSE_CALL(option, func, pi, obj) \
|
36
|
+
if (RB_UNLIKELY(Yes == option)) { \
|
37
|
+
oj_trace_parse_call(func, pi, __FILE__, __LINE__, obj); \
|
38
|
+
}
|
39
|
+
#define TRACE_PARSE_HASH_END(option, pi) \
|
40
|
+
if (RB_UNLIKELY(Yes == option)) { \
|
41
|
+
oj_trace_parse_hash_end(pi, __FILE__, __LINE__); \
|
42
|
+
}
|
43
|
+
#define TRACE_PARSE_ARRAY_END(option, pi) \
|
44
|
+
if (RB_UNLIKELY(Yes == option)) { \
|
45
|
+
oj_trace_parse_array_end(pi, __FILE__, __LINE__); \
|
46
|
+
}
|
47
|
+
#else
|
48
|
+
#define TRACE(option, func, obj, depth, where)
|
49
|
+
#define TRACE_PARSE_IN(option, func, pi)
|
50
|
+
#define TRACE_PARSE_CALL(option, func, pi, obj)
|
51
|
+
#define TRACE_PARSE_HASH_END(option, pi)
|
52
|
+
#define TRACE_PARSE_ARRAY_END(option, pi)
|
53
|
+
#endif
|
54
|
+
|
28
55
|
#endif /* OJ_TRACE_H */
|