oj 3.11.0 → 3.11.5
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/README.md +2 -1
- data/ext/oj/buf.h +34 -38
- data/ext/oj/cache8.c +59 -62
- data/ext/oj/cache8.h +8 -7
- data/ext/oj/circarray.c +33 -35
- data/ext/oj/circarray.h +11 -9
- data/ext/oj/code.c +170 -174
- data/ext/oj/code.h +21 -20
- data/ext/oj/compat.c +159 -166
- data/ext/oj/custom.c +802 -851
- data/ext/oj/dump.c +766 -778
- data/ext/oj/dump.h +49 -51
- data/ext/oj/dump_compat.c +1 -0
- data/ext/oj/dump_leaf.c +116 -157
- data/ext/oj/dump_object.c +609 -628
- data/ext/oj/dump_strict.c +318 -327
- data/ext/oj/encode.h +3 -4
- data/ext/oj/err.c +39 -25
- data/ext/oj/err.h +24 -15
- data/ext/oj/extconf.rb +2 -1
- data/ext/oj/fast.c +1008 -1038
- data/ext/oj/hash.c +62 -66
- data/ext/oj/hash.h +7 -6
- data/ext/oj/hash_test.c +450 -443
- data/ext/oj/mimic_json.c +413 -402
- data/ext/oj/object.c +559 -528
- data/ext/oj/odd.c +123 -128
- data/ext/oj/odd.h +27 -25
- data/ext/oj/oj.c +1131 -924
- data/ext/oj/oj.h +286 -298
- data/ext/oj/parse.c +938 -930
- data/ext/oj/parse.h +70 -69
- data/ext/oj/rails.c +836 -839
- data/ext/oj/rails.h +7 -7
- data/ext/oj/reader.c +135 -140
- data/ext/oj/reader.h +66 -79
- data/ext/oj/resolve.c +43 -43
- data/ext/oj/resolve.h +3 -2
- data/ext/oj/rxclass.c +67 -68
- data/ext/oj/rxclass.h +12 -10
- data/ext/oj/saj.c +451 -479
- data/ext/oj/scp.c +93 -103
- data/ext/oj/sparse.c +770 -730
- data/ext/oj/stream_writer.c +120 -149
- data/ext/oj/strict.c +71 -86
- data/ext/oj/string_writer.c +198 -243
- data/ext/oj/trace.c +29 -33
- data/ext/oj/trace.h +14 -11
- data/ext/oj/util.c +103 -103
- data/ext/oj/util.h +3 -2
- data/ext/oj/val_stack.c +47 -47
- data/ext/oj/val_stack.h +79 -86
- data/ext/oj/wab.c +291 -309
- data/lib/oj/bag.rb +1 -0
- data/lib/oj/easy_hash.rb +5 -4
- data/lib/oj/mimic.rb +0 -12
- data/lib/oj/version.rb +1 -1
- data/test/activerecord/result_test.rb +7 -2
- data/test/foo.rb +35 -32
- data/test/helper.rb +10 -0
- data/test/json_gem/json_generator_test.rb +15 -3
- data/test/json_gem/test_helper.rb +8 -0
- data/test/test_compat.rb +2 -2
- data/test/test_generate.rb +21 -0
- data/test/test_hash.rb +10 -0
- data/test/test_scp.rb +1 -1
- metadata +4 -2
data/ext/oj/trace.c
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
// Copyright (c) 2018 Peter Ohler. All rights reserved.
|
2
|
+
// Licensed under the MIT License. See LICENSE file in the project root for license details.
|
2
3
|
|
3
|
-
#include "parse.h"
|
4
4
|
#include "trace.h"
|
5
5
|
|
6
|
-
#
|
6
|
+
#include "parse.h"
|
7
|
+
|
8
|
+
#define MAX_INDENT 256
|
7
9
|
|
8
|
-
static void
|
9
|
-
fill_indent(char *indent, int depth) {
|
10
|
+
static void fill_indent(char *indent, int depth) {
|
10
11
|
if (MAX_INDENT <= depth) {
|
11
|
-
|
12
|
+
depth = MAX_INDENT - 1;
|
12
13
|
} else if (depth < 0) {
|
13
|
-
|
14
|
+
depth = 0;
|
14
15
|
}
|
15
16
|
if (0 < depth) {
|
16
|
-
|
17
|
+
memset(indent, ' ', depth);
|
17
18
|
}
|
18
19
|
indent[depth] = '\0';
|
19
20
|
}
|
20
21
|
|
21
|
-
void
|
22
|
-
|
23
|
-
char
|
24
|
-
char indent[MAX_INDENT];
|
22
|
+
void oj_trace(const char *func, VALUE obj, const char *file, int line, int depth, TraceWhere where) {
|
23
|
+
char fmt[64];
|
24
|
+
char indent[MAX_INDENT];
|
25
25
|
|
26
26
|
depth *= 2;
|
27
27
|
fill_indent(indent, depth);
|
@@ -29,46 +29,42 @@ oj_trace(const char *func, VALUE obj, const char *file, int line, int depth, Tra
|
|
29
29
|
printf(fmt, file, line, indent, func, rb_obj_classname(obj));
|
30
30
|
}
|
31
31
|
|
32
|
-
void
|
33
|
-
|
34
|
-
char
|
35
|
-
|
36
|
-
int depth = (int)(stack_size(&pi->stack) * 2);
|
32
|
+
void oj_trace_parse_call(const char *func, ParseInfo pi, const char *file, int line, VALUE obj) {
|
33
|
+
char fmt[64];
|
34
|
+
char indent[MAX_INDENT];
|
35
|
+
int depth = (int)(stack_size(&pi->stack) * 2);
|
37
36
|
|
38
37
|
fill_indent(indent, depth);
|
39
38
|
sprintf(fmt, "#0:%%13s:%%3d:Oj:-:%%%ds %%s %%s\n", depth);
|
40
39
|
printf(fmt, file, line, indent, func, rb_obj_classname(obj));
|
41
40
|
}
|
42
41
|
|
43
|
-
void
|
44
|
-
|
45
|
-
char
|
46
|
-
|
47
|
-
int depth = (int)(stack_size(&pi->stack) * 2);
|
42
|
+
void oj_trace_parse_in(const char *func, ParseInfo pi, const char *file, int line) {
|
43
|
+
char fmt[64];
|
44
|
+
char indent[MAX_INDENT];
|
45
|
+
int depth = (int)(stack_size(&pi->stack) * 2);
|
48
46
|
|
49
47
|
fill_indent(indent, depth);
|
50
48
|
sprintf(fmt, "#0:%%13s:%%3d:Oj:}:%%%ds %%s\n", depth);
|
51
49
|
printf(fmt, file, line, indent, func);
|
52
50
|
}
|
53
51
|
|
54
|
-
void
|
55
|
-
|
56
|
-
char
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
VALUE obj = v->val;
|
52
|
+
void oj_trace_parse_hash_end(ParseInfo pi, const char *file, int line) {
|
53
|
+
char fmt[64];
|
54
|
+
char indent[MAX_INDENT];
|
55
|
+
int depth = (int)(stack_size(&pi->stack) * 2 - 2);
|
56
|
+
Val v = stack_peek(&pi->stack);
|
57
|
+
VALUE obj = v->val;
|
61
58
|
|
62
59
|
fill_indent(indent, depth);
|
63
60
|
sprintf(fmt, "#0:%%13s:%%3d:Oj:{:%%%ds hash_end %%s\n", depth);
|
64
61
|
printf(fmt, file, line, indent, rb_obj_classname(obj));
|
65
62
|
}
|
66
63
|
|
67
|
-
void
|
68
|
-
|
69
|
-
char
|
70
|
-
|
71
|
-
int depth = (int)(stack_size(&pi->stack) * 2);
|
64
|
+
void oj_trace_parse_array_end(ParseInfo pi, const char *file, int line) {
|
65
|
+
char fmt[64];
|
66
|
+
char indent[MAX_INDENT];
|
67
|
+
int depth = (int)(stack_size(&pi->stack) * 2);
|
72
68
|
|
73
69
|
fill_indent(indent, depth);
|
74
70
|
sprintf(fmt, "#0:%%13s:%%3d:Oj:{:%%%ds array_ned\n", depth);
|
data/ext/oj/trace.h
CHANGED
@@ -1,25 +1,28 @@
|
|
1
1
|
// Copyright (c) 2018 Peter Ohler. All rights reserved.
|
2
|
+
// Licensed under the MIT License. See LICENSE file in the project root for license details.
|
2
3
|
|
3
4
|
#ifndef OJ_TRACE_H
|
4
5
|
#define OJ_TRACE_H
|
5
6
|
|
6
|
-
#include <stdbool.h>
|
7
7
|
#include <ruby.h>
|
8
|
+
#include <stdbool.h>
|
8
9
|
|
9
10
|
typedef enum {
|
10
|
-
TraceIn
|
11
|
-
TraceOut
|
12
|
-
TraceCall
|
13
|
-
TraceRubyIn
|
14
|
-
TraceRubyOut
|
11
|
+
TraceIn = '}',
|
12
|
+
TraceOut = '{',
|
13
|
+
TraceCall = '-',
|
14
|
+
TraceRubyIn = '>',
|
15
|
+
TraceRubyOut = '<',
|
15
16
|
} TraceWhere;
|
16
17
|
|
17
18
|
struct _parseInfo;
|
18
19
|
|
19
|
-
extern void
|
20
|
-
|
21
|
-
extern void
|
22
|
-
extern void
|
23
|
-
|
20
|
+
extern void
|
21
|
+
oj_trace(const char *func, VALUE obj, const char *file, int line, int depth, TraceWhere where);
|
22
|
+
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);
|
25
|
+
extern void oj_trace_parse_hash_end(struct _parseInfo *pi, const char *file, int line);
|
26
|
+
extern void oj_trace_parse_array_end(struct _parseInfo *pi, const char *file, int line);
|
24
27
|
|
25
28
|
#endif /* OJ_TRACE_H */
|
data/ext/oj/util.c
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
// Copyright (c) 2019 Peter Ohler. All rights reserved.
|
2
|
+
// Licensed under the MIT License. See LICENSE file in the project root for license details.
|
2
3
|
|
3
4
|
#include "util.h"
|
4
5
|
|
@@ -8,129 +9,128 @@
|
|
8
9
|
#include <string.h>
|
9
10
|
#include <time.h>
|
10
11
|
|
11
|
-
#define SECS_PER_DAY
|
12
|
-
#define SECS_PER_YEAR
|
13
|
-
#define SECS_PER_LEAP
|
14
|
-
#define SECS_PER_QUAD_YEAR
|
15
|
-
#define SECS_PER_CENT
|
16
|
-
#define SECS_PER_LEAP_CENT
|
17
|
-
#define SECS_PER_QUAD_CENT
|
12
|
+
#define SECS_PER_DAY 86400LL
|
13
|
+
#define SECS_PER_YEAR 31536000LL
|
14
|
+
#define SECS_PER_LEAP 31622400LL
|
15
|
+
#define SECS_PER_QUAD_YEAR (SECS_PER_YEAR * 3 + SECS_PER_LEAP)
|
16
|
+
#define SECS_PER_CENT (SECS_PER_QUAD_YEAR * 24 + SECS_PER_YEAR * 4)
|
17
|
+
#define SECS_PER_LEAP_CENT (SECS_PER_CENT + SECS_PER_DAY)
|
18
|
+
#define SECS_PER_QUAD_CENT (SECS_PER_CENT * 4 + SECS_PER_DAY)
|
18
19
|
|
19
|
-
static int64_t
|
20
|
-
2678400,
|
21
|
-
5097600,
|
22
|
-
7776000,
|
23
|
-
10368000,
|
24
|
-
13046400,
|
25
|
-
15638400,
|
26
|
-
18316800,
|
27
|
-
20995200,
|
28
|
-
23587200,
|
29
|
-
26265600,
|
30
|
-
28857600,
|
31
|
-
31536000,
|
20
|
+
static int64_t eom_secs[] = {
|
21
|
+
2678400, // January (31)
|
22
|
+
5097600, // February (28) 2419200 2505600
|
23
|
+
7776000, // March (31)
|
24
|
+
10368000, // April (30 2592000
|
25
|
+
13046400, // May (31)
|
26
|
+
15638400, // June (30)
|
27
|
+
18316800, // July (31)
|
28
|
+
20995200, // August (31)
|
29
|
+
23587200, // September (30)
|
30
|
+
26265600, // October (31)
|
31
|
+
28857600, // November (30)
|
32
|
+
31536000, // December (31)
|
32
33
|
};
|
33
34
|
|
34
|
-
static int64_t
|
35
|
-
2678400,
|
36
|
-
5184000,
|
37
|
-
7862400,
|
38
|
-
10454400,
|
39
|
-
13132800,
|
40
|
-
15724800,
|
41
|
-
18403200,
|
42
|
-
21081600,
|
43
|
-
23673600,
|
44
|
-
26352000,
|
45
|
-
28944000,
|
46
|
-
31622400,
|
35
|
+
static int64_t eom_leap_secs[] = {
|
36
|
+
2678400, // January (31)
|
37
|
+
5184000, // February (28) 2419200 2505600
|
38
|
+
7862400, // March (31)
|
39
|
+
10454400, // April (30 2592000
|
40
|
+
13132800, // May (31)
|
41
|
+
15724800, // June (30)
|
42
|
+
18403200, // July (31)
|
43
|
+
21081600, // August (31)
|
44
|
+
23673600, // September (30)
|
45
|
+
26352000, // October (31)
|
46
|
+
28944000, // November (30)
|
47
|
+
31622400, // December (31)
|
47
48
|
};
|
48
49
|
|
50
|
+
void sec_as_time(int64_t secs, TimeInfo ti) {
|
51
|
+
int64_t qc = 0;
|
52
|
+
int64_t c = 0;
|
53
|
+
int64_t qy = 0;
|
54
|
+
int64_t y = 0;
|
55
|
+
bool leap = false;
|
56
|
+
int64_t *ms;
|
57
|
+
int m;
|
58
|
+
int shift = 0;
|
49
59
|
|
50
|
-
|
51
|
-
sec_as_time(int64_t secs, TimeInfo ti) {
|
52
|
-
int64_t qc = 0;
|
53
|
-
int64_t c = 0;
|
54
|
-
int64_t qy = 0;
|
55
|
-
int64_t y = 0;
|
56
|
-
bool leap = false;
|
57
|
-
int64_t *ms;
|
58
|
-
int m;
|
59
|
-
int shift = 0;
|
60
|
-
|
61
|
-
secs += 62167219200LL; // normalize to first day of the year 0
|
60
|
+
secs += 62167219200LL; // normalize to first day of the year 0
|
62
61
|
if (secs < 0) {
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
shift = -secs / SECS_PER_QUAD_CENT;
|
63
|
+
shift++;
|
64
|
+
secs += shift * SECS_PER_QUAD_CENT;
|
66
65
|
}
|
67
|
-
qc
|
66
|
+
qc = secs / SECS_PER_QUAD_CENT;
|
68
67
|
secs = secs - qc * SECS_PER_QUAD_CENT;
|
69
68
|
if (secs < SECS_PER_LEAP) {
|
70
|
-
|
69
|
+
leap = true;
|
71
70
|
} else if (secs < SECS_PER_QUAD_YEAR) {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
} else if (secs < SECS_PER_LEAP_CENT) {
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
71
|
+
if (SECS_PER_LEAP <= secs) {
|
72
|
+
secs -= SECS_PER_LEAP;
|
73
|
+
y = secs / SECS_PER_YEAR;
|
74
|
+
secs = secs - y * SECS_PER_YEAR;
|
75
|
+
y++;
|
76
|
+
leap = false;
|
77
|
+
}
|
78
|
+
} else if (secs < SECS_PER_LEAP_CENT) { // first century in 400 years is a leap century (one
|
79
|
+
// extra day)
|
80
|
+
qy = secs / SECS_PER_QUAD_YEAR;
|
81
|
+
secs = secs - qy * SECS_PER_QUAD_YEAR;
|
82
|
+
if (secs < SECS_PER_LEAP) {
|
83
|
+
leap = true;
|
84
|
+
} else {
|
85
|
+
secs -= SECS_PER_LEAP;
|
86
|
+
y = secs / SECS_PER_YEAR;
|
87
|
+
secs = secs - y * SECS_PER_YEAR;
|
88
|
+
y++;
|
89
|
+
}
|
90
90
|
} else {
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
91
|
+
secs -= SECS_PER_LEAP_CENT;
|
92
|
+
c = secs / SECS_PER_CENT;
|
93
|
+
secs = secs - c * SECS_PER_CENT;
|
94
|
+
c++;
|
95
|
+
if (secs < SECS_PER_YEAR * 4) {
|
96
|
+
y = secs / SECS_PER_YEAR;
|
97
|
+
secs = secs - y * SECS_PER_YEAR;
|
98
|
+
} else {
|
99
|
+
secs -= SECS_PER_YEAR * 4;
|
100
|
+
qy = secs / SECS_PER_QUAD_YEAR;
|
101
|
+
secs = secs - qy * SECS_PER_QUAD_YEAR;
|
102
|
+
qy++;
|
103
|
+
if (secs < SECS_PER_LEAP) {
|
104
|
+
leap = true;
|
105
|
+
} else {
|
106
|
+
secs -= SECS_PER_LEAP;
|
107
|
+
y = secs / SECS_PER_YEAR;
|
108
|
+
secs = secs - y * SECS_PER_YEAR;
|
109
|
+
y++;
|
110
|
+
}
|
111
|
+
}
|
112
112
|
}
|
113
113
|
ti->year = (int)((qc - (int64_t)shift) * 400 + c * 100 + qy * 4 + y);
|
114
114
|
if (leap) {
|
115
|
-
|
115
|
+
ms = eom_leap_secs;
|
116
116
|
} else {
|
117
|
-
|
117
|
+
ms = eom_secs;
|
118
118
|
}
|
119
119
|
for (m = 1; m <= 12; m++, ms++) {
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
120
|
+
if (secs < *ms) {
|
121
|
+
if (1 < m) {
|
122
|
+
secs -= *(ms - 1);
|
123
|
+
}
|
124
|
+
ti->mon = m;
|
125
|
+
break;
|
126
|
+
}
|
127
127
|
}
|
128
128
|
ti->day = (int)(secs / 86400LL);
|
129
|
-
secs
|
129
|
+
secs = secs - (int64_t)ti->day * 86400LL;
|
130
130
|
ti->day++;
|
131
131
|
ti->hour = (int)(secs / 3600LL);
|
132
|
-
secs
|
133
|
-
ti->min
|
134
|
-
secs
|
135
|
-
ti->sec
|
132
|
+
secs = secs - (int64_t)ti->hour * 3600LL;
|
133
|
+
ti->min = (int)(secs / 60LL);
|
134
|
+
secs = secs - (int64_t)ti->min * 60LL;
|
135
|
+
ti->sec = (int)secs;
|
136
136
|
}
|
data/ext/oj/util.h
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
// Copyright (c) 2019 Peter Ohler. All rights reserved.
|
2
|
+
// Licensed under the MIT License. See LICENSE file in the project root for license details.
|
2
3
|
|
3
4
|
#ifndef OJ_UTIL_H
|
4
5
|
#define OJ_UTIL_H
|
@@ -12,8 +13,8 @@ typedef struct _timeInfo {
|
|
12
13
|
int day;
|
13
14
|
int mon;
|
14
15
|
int year;
|
15
|
-
} *TimeInfo;
|
16
|
+
} * TimeInfo;
|
16
17
|
|
17
|
-
extern void
|
18
|
+
extern void sec_as_time(int64_t secs, TimeInfo ti);
|
18
19
|
|
19
20
|
#endif /* OJ_UTIL_H */
|
data/ext/oj/val_stack.c
CHANGED
@@ -1,18 +1,19 @@
|
|
1
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 "val_stack.h"
|
2
5
|
|
3
6
|
#include <string.h>
|
4
7
|
|
5
|
-
#include "oj.h"
|
6
8
|
#include "odd.h"
|
7
|
-
#include "
|
9
|
+
#include "oj.h"
|
8
10
|
|
9
|
-
static void
|
10
|
-
|
11
|
-
|
12
|
-
Val v;
|
11
|
+
static void mark(void *ptr) {
|
12
|
+
ValStack stack = (ValStack)ptr;
|
13
|
+
Val v;
|
13
14
|
|
14
15
|
if (0 == ptr) {
|
15
|
-
|
16
|
+
return;
|
16
17
|
}
|
17
18
|
#ifdef HAVE_PTHREAD_MUTEX_INIT
|
18
19
|
pthread_mutex_lock(&stack->mutex);
|
@@ -21,22 +22,22 @@ mark(void *ptr) {
|
|
21
22
|
rb_gc_mark(stack->mutex);
|
22
23
|
#endif
|
23
24
|
for (v = stack->head; v < stack->tail; v++) {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
if (Qnil != v->val && Qundef != v->val) {
|
26
|
+
rb_gc_mark(v->val);
|
27
|
+
}
|
28
|
+
if (Qnil != v->key_val && Qundef != v->key_val) {
|
29
|
+
rb_gc_mark(v->key_val);
|
30
|
+
}
|
31
|
+
if (NULL != v->odd_args) {
|
32
|
+
VALUE *a;
|
33
|
+
int i;
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
for (i = v->odd_args->odd->attr_cnt, a = v->odd_args->args; 0 < i; i--, a++) {
|
36
|
+
if (Qnil != *a) {
|
37
|
+
rb_gc_mark(*a);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
40
41
|
}
|
41
42
|
#ifdef HAVE_PTHREAD_MUTEX_INIT
|
42
43
|
pthread_mutex_unlock(&stack->mutex);
|
@@ -48,43 +49,42 @@ mark(void *ptr) {
|
|
48
49
|
VALUE
|
49
50
|
oj_stack_init(ValStack stack) {
|
50
51
|
#ifdef HAVE_PTHREAD_MUTEX_INIT
|
51
|
-
int
|
52
|
+
int err;
|
52
53
|
|
53
54
|
if (0 != (err = pthread_mutex_init(&stack->mutex, 0))) {
|
54
|
-
|
55
|
+
rb_raise(rb_eException, "failed to initialize a mutex. %s", strerror(err));
|
55
56
|
}
|
56
57
|
#else
|
57
58
|
stack->mutex = rb_mutex_new();
|
58
59
|
#endif
|
59
|
-
stack->head
|
60
|
-
stack->end
|
61
|
-
stack->tail
|
62
|
-
stack->head->val
|
63
|
-
stack->head->key
|
64
|
-
stack->head->key_val
|
60
|
+
stack->head = stack->base;
|
61
|
+
stack->end = stack->base + sizeof(stack->base) / sizeof(struct _val);
|
62
|
+
stack->tail = stack->head;
|
63
|
+
stack->head->val = Qundef;
|
64
|
+
stack->head->key = NULL;
|
65
|
+
stack->head->key_val = Qundef;
|
65
66
|
stack->head->classname = NULL;
|
66
|
-
stack->head->odd_args
|
67
|
-
stack->head->clas
|
68
|
-
stack->head->klen
|
69
|
-
stack->head->clen
|
70
|
-
stack->head->next
|
67
|
+
stack->head->odd_args = NULL;
|
68
|
+
stack->head->clas = Qundef;
|
69
|
+
stack->head->klen = 0;
|
70
|
+
stack->head->clen = 0;
|
71
|
+
stack->head->next = NEXT_NONE;
|
71
72
|
|
72
73
|
return Data_Wrap_Struct(oj_cstack_class, mark, 0, stack);
|
73
74
|
}
|
74
75
|
|
75
|
-
const char*
|
76
|
-
oj_stack_next_string(ValNext n) {
|
76
|
+
const char *oj_stack_next_string(ValNext n) {
|
77
77
|
switch (n) {
|
78
|
-
case NEXT_ARRAY_NEW:
|
79
|
-
case NEXT_ARRAY_ELEMENT:
|
80
|
-
case NEXT_ARRAY_COMMA:
|
81
|
-
case NEXT_HASH_NEW:
|
82
|
-
case NEXT_HASH_KEY:
|
83
|
-
case NEXT_HASH_COLON:
|
84
|
-
case NEXT_HASH_VALUE:
|
85
|
-
case NEXT_HASH_COMMA:
|
86
|
-
case NEXT_NONE:
|
87
|
-
default:
|
78
|
+
case NEXT_ARRAY_NEW: return "array element or close";
|
79
|
+
case NEXT_ARRAY_ELEMENT: return "array element";
|
80
|
+
case NEXT_ARRAY_COMMA: return "comma";
|
81
|
+
case NEXT_HASH_NEW: return "hash pair or close";
|
82
|
+
case NEXT_HASH_KEY: return "hash key";
|
83
|
+
case NEXT_HASH_COLON: return "colon";
|
84
|
+
case NEXT_HASH_VALUE: return "hash value";
|
85
|
+
case NEXT_HASH_COMMA: return "comma";
|
86
|
+
case NEXT_NONE: break;
|
87
|
+
default: break;
|
88
88
|
}
|
89
89
|
return "nothing";
|
90
90
|
}
|