oj 3.7.5 → 3.7.6
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.
- checksums.yaml +4 -4
- data/ext/oj/buf.h +4 -4
- data/ext/oj/cache8.c +3 -3
- data/ext/oj/cache8.h +4 -4
- data/ext/oj/circarray.c +1 -1
- data/ext/oj/circarray.h +4 -4
- data/ext/oj/code.h +6 -6
- data/ext/oj/compat.c +5 -5
- data/ext/oj/custom.c +15 -13
- data/ext/oj/dump.c +15 -5
- data/ext/oj/dump.h +3 -3
- data/ext/oj/dump_compat.c +15 -11
- data/ext/oj/dump_leaf.c +1 -1
- data/ext/oj/dump_object.c +4 -2
- data/ext/oj/encode.h +3 -3
- data/ext/oj/err.c +1 -1
- data/ext/oj/err.h +5 -5
- data/ext/oj/fast.c +14 -14
- data/ext/oj/hash.c +7 -7
- data/ext/oj/hash.h +4 -4
- data/ext/oj/hash_test.c +2 -2
- data/ext/oj/mimic_json.c +9 -9
- data/ext/oj/object.c +3 -3
- data/ext/oj/odd.c +12 -8
- data/ext/oj/odd.h +5 -5
- data/ext/oj/oj.c +14 -12
- data/ext/oj/oj.h +23 -23
- data/ext/oj/parse.c +3 -3
- data/ext/oj/parse.h +26 -26
- data/ext/oj/rails.c +27 -23
- data/ext/oj/rails.h +3 -3
- data/ext/oj/reader.h +5 -5
- data/ext/oj/resolve.h +3 -3
- data/ext/oj/rxclass.c +5 -5
- data/ext/oj/rxclass.h +7 -7
- data/ext/oj/saj.c +2 -2
- data/ext/oj/scp.c +3 -3
- data/ext/oj/sparse.c +4 -4
- data/ext/oj/stream_writer.c +1 -1
- data/ext/oj/strict.c +6 -6
- data/ext/oj/string_writer.c +1 -1
- data/ext/oj/trace.h +8 -8
- data/ext/oj/val_stack.c +8 -2
- data/ext/oj/val_stack.h +9 -9
- data/ext/oj/wab.c +11 -7
- data/lib/oj/version.rb +1 -1
- data/test/bug.rb +51 -0
- data/test/bug2.rb +10 -0
- data/test/bug3.rb +46 -0
- data/test/bug_fast.rb +32 -0
- data/test/bug_load.rb +24 -0
- data/test/crash.rb +111 -0
- data/test/example.rb +11 -0
- data/test/foo.rb +4 -29
- data/test/io.rb +48 -0
- data/test/isolated/test_mimic_rails_datetime.rb +27 -0
- data/test/mem.rb +12 -27
- data/test/mod.rb +16 -0
- data/test/omit.rb +20 -0
- data/test/rails.rb +50 -0
- data/test/rails_datetime_test.rb +24 -0
- data/test/russian.rb +18 -0
- data/test/struct.rb +29 -0
- data/test/test_serializer.rb +59 -0
- data/test/write_timebars.rb +31 -0
- data/test/x_test.rb +185 -0
- metadata +102 -68
- data/test/big.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7289437b014edb9bb095abd9827815e3bea0efb62b4e5486d0034158c4811c1c
|
4
|
+
data.tar.gz: 5d341b6a90bb002d7324f55277010a78236b6338710b58f490e416001167e5fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f68b2fb4f0762ce86cdc9a1a56ecd42d377f485fc32d0f36cf1c0ef689eee14f73b76a3b77dd7ecd7c0d6cc3837064cb62ea201e705145af40a18aaa93cdfe8
|
7
|
+
data.tar.gz: 6406b48f3439c1340d23e1aea04fc6d781bbd0195012cdff94fbf81e409fd43978606d5fe0b61eca1c7ea635a8af16b1de876df92c3729d4ac96fb4d9951b239
|
data/ext/oj/buf.h
CHANGED
@@ -28,12 +28,12 @@
|
|
28
28
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
29
|
*/
|
30
30
|
|
31
|
-
#ifndef
|
32
|
-
#define
|
31
|
+
#ifndef OJ_BUF_H
|
32
|
+
#define OJ_BUF_H
|
33
33
|
|
34
34
|
#include "ruby.h"
|
35
35
|
|
36
|
-
typedef struct
|
36
|
+
typedef struct _buf {
|
37
37
|
char *head;
|
38
38
|
char *end;
|
39
39
|
char *tail;
|
@@ -100,4 +100,4 @@ buf_append(Buf buf, char c) {
|
|
100
100
|
//*buf->tail = '\0'; // for debugging
|
101
101
|
}
|
102
102
|
|
103
|
-
#endif /*
|
103
|
+
#endif /* OJ_BUF_H */
|
data/ext/oj/cache8.c
CHANGED
@@ -14,11 +14,11 @@
|
|
14
14
|
#define DEPTH 16
|
15
15
|
|
16
16
|
typedef union {
|
17
|
-
struct
|
17
|
+
struct _cache8 *child;
|
18
18
|
slot_t value;
|
19
19
|
} Bucket;
|
20
20
|
|
21
|
-
struct
|
21
|
+
struct _cache8 {
|
22
22
|
Bucket buckets[SLOT_CNT];
|
23
23
|
};
|
24
24
|
|
@@ -30,7 +30,7 @@ oj_cache8_new(Cache8 *cache) {
|
|
30
30
|
Bucket *b;
|
31
31
|
int i;
|
32
32
|
|
33
|
-
*cache = ALLOC(struct
|
33
|
+
*cache = ALLOC(struct _cache8);
|
34
34
|
for (i = SLOT_CNT, b = (*cache)->buckets; 0 < i; i--, b++) {
|
35
35
|
b->value = 0;
|
36
36
|
}
|
data/ext/oj/cache8.h
CHANGED
@@ -28,13 +28,13 @@
|
|
28
28
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
29
|
*/
|
30
30
|
|
31
|
-
#ifndef
|
32
|
-
#define
|
31
|
+
#ifndef OJ_CACHE8_H
|
32
|
+
#define OJ_CACHE8_H
|
33
33
|
|
34
34
|
#include "ruby.h"
|
35
35
|
#include "stdint.h"
|
36
36
|
|
37
|
-
typedef struct
|
37
|
+
typedef struct _cache8 *Cache8;
|
38
38
|
typedef uint64_t slot_t;
|
39
39
|
typedef uint64_t sid_t;
|
40
40
|
|
@@ -45,4 +45,4 @@ extern slot_t oj_cache8_get(Cache8 cache, sid_t key, slot_t **slot);
|
|
45
45
|
|
46
46
|
extern void oj_cache8_print(Cache8 cache);
|
47
47
|
|
48
|
-
#endif /*
|
48
|
+
#endif /* OJ_CACHE8_H */
|
data/ext/oj/circarray.c
CHANGED
data/ext/oj/circarray.h
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
* All rights reserved.
|
4
4
|
*/
|
5
5
|
|
6
|
-
#ifndef
|
7
|
-
#define
|
6
|
+
#ifndef OJ_CIRCARRAY_H
|
7
|
+
#define OJ_CIRCARRAY_H
|
8
8
|
|
9
9
|
#include "ruby.h"
|
10
10
|
|
11
|
-
typedef struct
|
11
|
+
typedef struct _circArray {
|
12
12
|
VALUE obj_array[1024];
|
13
13
|
VALUE *objs;
|
14
14
|
unsigned long size; // allocated size or initial array size
|
@@ -20,4 +20,4 @@ extern void oj_circ_array_free(CircArray ca);
|
|
20
20
|
extern void oj_circ_array_set(CircArray ca, VALUE obj, unsigned long id);
|
21
21
|
extern VALUE oj_circ_array_get(CircArray ca, unsigned long id);
|
22
22
|
|
23
|
-
#endif /*
|
23
|
+
#endif /* OJ_CIRCARRAY_H */
|
data/ext/oj/code.h
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
* All rights reserved.
|
4
4
|
*/
|
5
5
|
|
6
|
-
#ifndef
|
7
|
-
#define
|
6
|
+
#ifndef OJ_CODE_H
|
7
|
+
#define OJ_CODE_H
|
8
8
|
|
9
9
|
#include <ruby.h>
|
10
10
|
|
@@ -13,7 +13,7 @@
|
|
13
13
|
typedef void (*EncodeFunc)(VALUE obj, int depth, Out out);
|
14
14
|
typedef VALUE (*DecodeFunc)(VALUE clas, VALUE args);
|
15
15
|
|
16
|
-
typedef struct
|
16
|
+
typedef struct _code {
|
17
17
|
const char *name;
|
18
18
|
VALUE clas;
|
19
19
|
EncodeFunc encode;
|
@@ -22,7 +22,7 @@ typedef struct _Code {
|
|
22
22
|
} *Code;
|
23
23
|
|
24
24
|
// Used by encode functions.
|
25
|
-
typedef struct
|
25
|
+
typedef struct _attr {
|
26
26
|
const char *name;
|
27
27
|
int len;
|
28
28
|
VALUE value;
|
@@ -37,6 +37,6 @@ extern bool oj_code_has(Code codes, VALUE clas, bool encode);
|
|
37
37
|
|
38
38
|
extern void oj_code_attrs(VALUE obj, Attr attrs, int depth, Out out, bool with_class);
|
39
39
|
|
40
|
-
extern struct
|
40
|
+
extern struct _code oj_compat_codes[];
|
41
41
|
|
42
|
-
#endif /*
|
42
|
+
#endif /* OJ_CODE_H */
|
data/ext/oj/compat.c
CHANGED
@@ -78,7 +78,7 @@ start_hash(ParseInfo pi) {
|
|
78
78
|
}
|
79
79
|
|
80
80
|
static void
|
81
|
-
end_hash(struct
|
81
|
+
end_hash(struct _parseInfo *pi) {
|
82
82
|
Val parent = stack_peek(&pi->stack);
|
83
83
|
|
84
84
|
if (0 != parent->classname) {
|
@@ -144,7 +144,7 @@ add_num(ParseInfo pi, NumInfo ni) {
|
|
144
144
|
}
|
145
145
|
|
146
146
|
static void
|
147
|
-
hash_set_num(struct
|
147
|
+
hash_set_num(struct _parseInfo *pi, Val parent, NumInfo ni) {
|
148
148
|
volatile VALUE rval = oj_num_as_value(ni);
|
149
149
|
|
150
150
|
if (!oj_use_hash_alt && rb_cHash != rb_obj_class(parent->val)) {
|
@@ -242,7 +242,7 @@ oj_set_compat_callbacks(ParseInfo pi) {
|
|
242
242
|
|
243
243
|
VALUE
|
244
244
|
oj_compat_parse(int argc, VALUE *argv, VALUE self) {
|
245
|
-
struct
|
245
|
+
struct _parseInfo pi;
|
246
246
|
|
247
247
|
parse_info_init(&pi);
|
248
248
|
pi.options = oj_default_options;
|
@@ -263,7 +263,7 @@ oj_compat_parse(int argc, VALUE *argv, VALUE self) {
|
|
263
263
|
|
264
264
|
VALUE
|
265
265
|
oj_compat_load(int argc, VALUE *argv, VALUE self) {
|
266
|
-
struct
|
266
|
+
struct _parseInfo pi;
|
267
267
|
|
268
268
|
parse_info_init(&pi);
|
269
269
|
pi.options = oj_default_options;
|
@@ -284,7 +284,7 @@ oj_compat_load(int argc, VALUE *argv, VALUE self) {
|
|
284
284
|
|
285
285
|
VALUE
|
286
286
|
oj_compat_parse_cstr(int argc, VALUE *argv, char *json, size_t len) {
|
287
|
-
struct
|
287
|
+
struct _parseInfo pi;
|
288
288
|
|
289
289
|
parse_info_init(&pi);
|
290
290
|
pi.options = oj_default_options;
|
data/ext/oj/custom.c
CHANGED
@@ -21,7 +21,7 @@ extern VALUE oj_parse_xml_time(const char *str, int len); // from object.c
|
|
21
21
|
|
22
22
|
static void
|
23
23
|
dump_obj_str(VALUE obj, int depth, Out out) {
|
24
|
-
struct
|
24
|
+
struct _attr attrs[] = {
|
25
25
|
{ "s", 1, Qnil },
|
26
26
|
{ NULL, 0, Qnil },
|
27
27
|
};
|
@@ -55,7 +55,7 @@ static ID imag_id = 0;
|
|
55
55
|
|
56
56
|
static void
|
57
57
|
complex_dump(VALUE obj, int depth, Out out) {
|
58
|
-
struct
|
58
|
+
struct _attr attrs[] = {
|
59
59
|
{ "real", 4, Qnil },
|
60
60
|
{ "imag", 4, Qnil },
|
61
61
|
{ NULL, 0, Qnil },
|
@@ -82,7 +82,7 @@ complex_load(VALUE clas, VALUE args) {
|
|
82
82
|
static void
|
83
83
|
time_dump(VALUE obj, int depth, Out out) {
|
84
84
|
if (Yes == out->opts->create_ok) {
|
85
|
-
struct
|
85
|
+
struct _attr attrs[] = {
|
86
86
|
{ "time", 4, Qundef, 0, Qundef },
|
87
87
|
{ NULL, 0, Qnil },
|
88
88
|
};
|
@@ -103,7 +103,7 @@ time_dump(VALUE obj, int depth, Out out) {
|
|
103
103
|
static void
|
104
104
|
date_dump(VALUE obj, int depth, Out out) {
|
105
105
|
if (Yes == out->opts->create_ok) {
|
106
|
-
struct
|
106
|
+
struct _attr attrs[] = {
|
107
107
|
{ "s", 1, Qnil },
|
108
108
|
{ NULL, 0, Qnil },
|
109
109
|
};
|
@@ -169,7 +169,7 @@ static ID table_id = 0;
|
|
169
169
|
|
170
170
|
static void
|
171
171
|
openstruct_dump(VALUE obj, int depth, Out out) {
|
172
|
-
struct
|
172
|
+
struct _attr attrs[] = {
|
173
173
|
{ "table", 5, Qnil },
|
174
174
|
{ NULL, 0, Qnil },
|
175
175
|
};
|
@@ -191,7 +191,7 @@ openstruct_load(VALUE clas, VALUE args) {
|
|
191
191
|
|
192
192
|
static void
|
193
193
|
range_dump(VALUE obj, int depth, Out out) {
|
194
|
-
struct
|
194
|
+
struct _attr attrs[] = {
|
195
195
|
{ "begin", 5, Qnil },
|
196
196
|
{ "end", 3, Qnil },
|
197
197
|
{ "exclude", 7, Qnil },
|
@@ -220,7 +220,7 @@ static ID denominator_id = 0;
|
|
220
220
|
|
221
221
|
static void
|
222
222
|
rational_dump(VALUE obj, int depth, Out out) {
|
223
|
-
struct
|
223
|
+
struct _attr attrs[] = {
|
224
224
|
{ "numerator", 9, Qnil },
|
225
225
|
{ "denominator", 11, Qnil },
|
226
226
|
{ NULL, 0, Qnil },
|
@@ -262,7 +262,7 @@ time_load(VALUE clas, VALUE args) {
|
|
262
262
|
return args;
|
263
263
|
}
|
264
264
|
|
265
|
-
static struct
|
265
|
+
static struct _code codes[] = {
|
266
266
|
{ "BigDecimal", Qnil, bigdecimal_dump, NULL, true },
|
267
267
|
{ "Complex", Qnil, complex_dump, complex_load, true },
|
268
268
|
{ "Date", Qnil, date_dump, date_load, true },
|
@@ -459,7 +459,9 @@ dump_odd(VALUE obj, Odd odd, VALUE clas, int depth, Out out) {
|
|
459
459
|
ID i;
|
460
460
|
|
461
461
|
if (sizeof(nbuf) <= nlen) {
|
462
|
-
n2 = strdup(name)
|
462
|
+
if (NULL == (n2 = strdup(name))) {
|
463
|
+
rb_raise(rb_eNoMemError, "for attribute name.");
|
464
|
+
}
|
463
465
|
} else {
|
464
466
|
strcpy(n2, name);
|
465
467
|
}
|
@@ -997,7 +999,7 @@ hash_set_cstr(ParseInfo pi, Val kval, const char *str, size_t len, const char *o
|
|
997
999
|
}
|
998
1000
|
|
999
1001
|
static void
|
1000
|
-
end_hash(struct
|
1002
|
+
end_hash(struct _parseInfo *pi) {
|
1001
1003
|
Val parent = stack_peek(&pi->stack);
|
1002
1004
|
|
1003
1005
|
if (Qundef != parent->clas && parent->clas != rb_obj_class(parent->val)) {
|
@@ -1030,7 +1032,7 @@ calc_hash_key(ParseInfo pi, Val parent) {
|
|
1030
1032
|
}
|
1031
1033
|
|
1032
1034
|
static void
|
1033
|
-
hash_set_num(struct
|
1035
|
+
hash_set_num(struct _parseInfo *pi, Val kval, NumInfo ni) {
|
1034
1036
|
Val parent = stack_peek(&pi->stack);
|
1035
1037
|
volatile VALUE rval = oj_num_as_value(ni);
|
1036
1038
|
|
@@ -1146,7 +1148,7 @@ oj_set_custom_callbacks(ParseInfo pi) {
|
|
1146
1148
|
|
1147
1149
|
VALUE
|
1148
1150
|
oj_custom_parse(int argc, VALUE *argv, VALUE self) {
|
1149
|
-
struct
|
1151
|
+
struct _parseInfo pi;
|
1150
1152
|
|
1151
1153
|
parse_info_init(&pi);
|
1152
1154
|
pi.options = oj_default_options;
|
@@ -1166,7 +1168,7 @@ oj_custom_parse(int argc, VALUE *argv, VALUE self) {
|
|
1166
1168
|
|
1167
1169
|
VALUE
|
1168
1170
|
oj_custom_parse_cstr(int argc, VALUE *argv, char *json, size_t len) {
|
1169
|
-
struct
|
1171
|
+
struct _parseInfo pi;
|
1170
1172
|
|
1171
1173
|
parse_info_init(&pi);
|
1172
1174
|
pi.options = oj_default_options;
|
data/ext/oj/dump.c
CHANGED
@@ -398,17 +398,23 @@ oj_dump_time(VALUE obj, Out out, int withZone) {
|
|
398
398
|
long long nsec;
|
399
399
|
|
400
400
|
#ifdef HAVE_RB_TIME_TIMESPEC
|
401
|
-
|
401
|
+
// rb_time_timespec as well as rb_time_timeeval have a bug that causes an
|
402
|
+
// exception to be raised if a time is before 1970 on 32 bit systems so
|
403
|
+
// check the timespec size and use the ruby calls if a 32 bit system.
|
404
|
+
if (16 <= sizeof(struct timespec)) {
|
402
405
|
struct timespec ts = rb_time_timespec(obj);
|
403
406
|
|
404
407
|
sec = (long long)ts.tv_sec;
|
405
408
|
nsec = ts.tv_nsec;
|
409
|
+
} else {
|
410
|
+
sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
|
411
|
+
nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
|
406
412
|
}
|
407
413
|
#else
|
408
414
|
sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
|
409
415
|
nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
|
410
416
|
#endif
|
411
|
-
|
417
|
+
|
412
418
|
*b-- = '\0';
|
413
419
|
if (withZone) {
|
414
420
|
long tzsecs = NUM2LONG(rb_funcall2(obj, oj_utc_offset_id, 0, 0));
|
@@ -497,10 +503,14 @@ oj_dump_xml_time(VALUE obj, Out out) {
|
|
497
503
|
char tzsign = '+';
|
498
504
|
|
499
505
|
#ifdef HAVE_RB_TIME_TIMESPEC
|
500
|
-
{
|
506
|
+
if (16 <= sizeof(struct timespec)) {
|
501
507
|
struct timespec ts = rb_time_timespec(obj);
|
508
|
+
|
502
509
|
sec = ts.tv_sec;
|
503
510
|
nsec = ts.tv_nsec;
|
511
|
+
} else {
|
512
|
+
sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
|
513
|
+
nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
|
504
514
|
}
|
505
515
|
#else
|
506
516
|
sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
|
@@ -644,7 +654,7 @@ oj_dump_obj_to_json_using_params(VALUE obj, Options copts, Out out, int argc, VA
|
|
644
654
|
void
|
645
655
|
oj_write_obj_to_file(VALUE obj, const char *path, Options copts) {
|
646
656
|
char buf[4096];
|
647
|
-
struct
|
657
|
+
struct _out out;
|
648
658
|
size_t size;
|
649
659
|
FILE *f;
|
650
660
|
int ok;
|
@@ -676,7 +686,7 @@ oj_write_obj_to_file(VALUE obj, const char *path, Options copts) {
|
|
676
686
|
void
|
677
687
|
oj_write_obj_to_stream(VALUE obj, VALUE stream, Options copts) {
|
678
688
|
char buf[4096];
|
679
|
-
struct
|
689
|
+
struct _out out;
|
680
690
|
ssize_t size;
|
681
691
|
VALUE clas = rb_obj_class(stream);
|
682
692
|
#if !IS_WINDOWS
|
data/ext/oj/dump.h
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
* All rights reserved.
|
4
4
|
*/
|
5
5
|
|
6
|
-
#ifndef
|
7
|
-
#define
|
6
|
+
#ifndef OJ_DUMP_H
|
7
|
+
#define OJ_DUMP_H
|
8
8
|
|
9
9
|
#include <ruby.h>
|
10
10
|
|
@@ -91,4 +91,4 @@ dump_ulong(unsigned long num, Out out) {
|
|
91
91
|
*out->cur = '\0';
|
92
92
|
}
|
93
93
|
|
94
|
-
#endif /*
|
94
|
+
#endif /* OJ_DUMP_H */
|
data/ext/oj/dump_compat.c
CHANGED
@@ -217,7 +217,7 @@ static ID _dump_id = 0;
|
|
217
217
|
|
218
218
|
static void
|
219
219
|
bigdecimal_alt(VALUE obj, int depth, Out out) {
|
220
|
-
struct
|
220
|
+
struct _attr attrs[] = {
|
221
221
|
{ "b", 1, Qnil },
|
222
222
|
{ NULL, 0, Qnil },
|
223
223
|
};
|
@@ -235,7 +235,7 @@ static ID imag_id = 0;
|
|
235
235
|
|
236
236
|
static void
|
237
237
|
complex_alt(VALUE obj, int depth, Out out) {
|
238
|
-
struct
|
238
|
+
struct _attr attrs[] = {
|
239
239
|
{ "r", 1, Qnil },
|
240
240
|
{ "i", 1, Qnil },
|
241
241
|
{ NULL, 0, Qnil },
|
@@ -258,7 +258,7 @@ static ID start_id = 0;
|
|
258
258
|
|
259
259
|
static void
|
260
260
|
date_alt(VALUE obj, int depth, Out out) {
|
261
|
-
struct
|
261
|
+
struct _attr attrs[] = {
|
262
262
|
{ "y", 1, Qnil },
|
263
263
|
{ "m", 1, Qnil },
|
264
264
|
{ "d", 1, Qnil },
|
@@ -286,7 +286,7 @@ static ID offset_id = 0;
|
|
286
286
|
|
287
287
|
static void
|
288
288
|
datetime_alt(VALUE obj, int depth, Out out) {
|
289
|
-
struct
|
289
|
+
struct _attr attrs[] = {
|
290
290
|
{ "y", 1, Qnil },
|
291
291
|
{ "m", 1, Qnil },
|
292
292
|
{ "d", 1, Qnil },
|
@@ -375,7 +375,7 @@ static ID table_id = 0;
|
|
375
375
|
|
376
376
|
static void
|
377
377
|
openstruct_alt(VALUE obj, int depth, Out out) {
|
378
|
-
struct
|
378
|
+
struct _attr attrs[] = {
|
379
379
|
{ "t", 1, Qnil },
|
380
380
|
{ NULL, 0, Qnil },
|
381
381
|
};
|
@@ -425,7 +425,7 @@ static ID denominator_id = 0;
|
|
425
425
|
|
426
426
|
static void
|
427
427
|
rational_alt(VALUE obj, int depth, Out out) {
|
428
|
-
struct
|
428
|
+
struct _attr attrs[] = {
|
429
429
|
{ "n", 1, Qnil },
|
430
430
|
{ "d", 1, Qnil },
|
431
431
|
{ NULL, 0, Qnil },
|
@@ -445,7 +445,7 @@ static ID source_id = 0;
|
|
445
445
|
|
446
446
|
static void
|
447
447
|
regexp_alt(VALUE obj, int depth, Out out) {
|
448
|
-
struct
|
448
|
+
struct _attr attrs[] = {
|
449
449
|
{ "o", 1, Qnil },
|
450
450
|
{ "s", 1, Qnil },
|
451
451
|
{ NULL, 0, Qnil },
|
@@ -462,7 +462,7 @@ regexp_alt(VALUE obj, int depth, Out out) {
|
|
462
462
|
|
463
463
|
static void
|
464
464
|
time_alt(VALUE obj, int depth, Out out) {
|
465
|
-
struct
|
465
|
+
struct _attr attrs[] = {
|
466
466
|
{ "s", 1, Qundef, 0, Qundef },
|
467
467
|
{ "n", 1, Qundef, 0, Qundef },
|
468
468
|
{ NULL, 0, Qnil },
|
@@ -471,10 +471,14 @@ time_alt(VALUE obj, int depth, Out out) {
|
|
471
471
|
long long nsec;
|
472
472
|
|
473
473
|
#ifdef HAVE_RB_TIME_TIMESPEC
|
474
|
-
{
|
474
|
+
if (16 <= sizeof(struct timespec)) {
|
475
475
|
struct timespec ts = rb_time_timespec(obj);
|
476
|
-
|
476
|
+
|
477
|
+
sec = (long long)ts.tv_sec;
|
477
478
|
nsec = ts.tv_nsec;
|
479
|
+
} else {
|
480
|
+
sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
|
481
|
+
nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
|
478
482
|
}
|
479
483
|
#else
|
480
484
|
sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
|
@@ -487,7 +491,7 @@ time_alt(VALUE obj, int depth, Out out) {
|
|
487
491
|
oj_code_attrs(obj, attrs, depth, out, true);
|
488
492
|
}
|
489
493
|
|
490
|
-
struct
|
494
|
+
struct _code oj_compat_codes[] = {
|
491
495
|
{ "BigDecimal", Qnil, bigdecimal_alt, NULL, false },
|
492
496
|
{ "Complex", Qnil, complex_alt, NULL, false },
|
493
497
|
{ "Date", Qnil, date_alt, false },
|