blob: fe918330389d04651839caa6581fa00b7451e6d2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
(* Auto-generated from "reaction.atd" *)
[@@@ocaml.warning "-27-32-35-39"]
type emoji = Emoji_t.t
type t = Reaction_t.t = { count: int; emoji: emoji }
let write_emoji = (
Emoji_j.write_t
)
let string_of_emoji ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_emoji ob x;
Bi_outbuf.contents ob
let read_emoji = (
Emoji_j.read_t
)
let emoji_of_string s =
read_emoji (Yojson.Safe.init_lexer ()) (Lexing.from_string s)
let write_t : _ -> t -> _ = (
fun ob x ->
Bi_outbuf.add_char ob '{';
let is_first = ref true in
if !is_first then
is_first := false
else
Bi_outbuf.add_char ob ',';
Bi_outbuf.add_string ob "\"count\":";
(
Yojson.Safe.write_int
)
ob x.count;
if !is_first then
is_first := false
else
Bi_outbuf.add_char ob ',';
Bi_outbuf.add_string ob "\"emoji\":";
(
write_emoji
)
ob x.emoji;
Bi_outbuf.add_char ob '}';
)
let string_of_t ?(len = 1024) x =
let ob = Bi_outbuf.create len in
write_t ob x;
Bi_outbuf.contents ob
let read_t = (
fun p lb ->
Yojson.Safe.read_space p lb;
Yojson.Safe.read_lcurl p lb;
let field_count = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let field_emoji = ref (Obj.magic (Sys.opaque_identity 0.0)) in
let bits0 = ref 0 in
try
Yojson.Safe.read_space p lb;
Yojson.Safe.read_object_end lb;
Yojson.Safe.read_space p lb;
let f =
fun s pos len ->
if pos < 0 || len < 0 || pos + len > String.length s then
invalid_arg "out-of-bounds substring position or length";
if len = 5 then (
match String.unsafe_get s pos with
| 'c' -> (
if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 't' then (
0
)
else (
-1
)
)
| 'e' -> (
if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'j' && String.unsafe_get s (pos+4) = 'i' then (
1
)
else (
-1
)
)
| _ -> (
-1
)
)
else (
-1
)
in
let i = Yojson.Safe.map_ident p f lb in
Atdgen_runtime.Oj_run.read_until_field_value p lb;
(
match i with
| 0 ->
field_count := (
(
Atdgen_runtime.Oj_run.read_int
) p lb
);
bits0 := !bits0 lor 0x1;
| 1 ->
field_emoji := (
(
read_emoji
) p lb
);
bits0 := !bits0 lor 0x2;
| _ -> (
Yojson.Safe.skip_json p lb
)
);
while true do
Yojson.Safe.read_space p lb;
Yojson.Safe.read_object_sep p lb;
Yojson.Safe.read_space p lb;
let f =
fun s pos len ->
if pos < 0 || len < 0 || pos + len > String.length s then
invalid_arg "out-of-bounds substring position or length";
if len = 5 then (
match String.unsafe_get s pos with
| 'c' -> (
if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 't' then (
0
)
else (
-1
)
)
| 'e' -> (
if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'j' && String.unsafe_get s (pos+4) = 'i' then (
1
)
else (
-1
)
)
| _ -> (
-1
)
)
else (
-1
)
in
let i = Yojson.Safe.map_ident p f lb in
Atdgen_runtime.Oj_run.read_until_field_value p lb;
(
match i with
| 0 ->
field_count := (
(
Atdgen_runtime.Oj_run.read_int
) p lb
);
bits0 := !bits0 lor 0x1;
| 1 ->
field_emoji := (
(
read_emoji
) p lb
);
bits0 := !bits0 lor 0x2;
| _ -> (
Yojson.Safe.skip_json p lb
)
);
done;
assert false;
with Yojson.End_of_object -> (
if !bits0 <> 0x3 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "count"; "emoji" |];
(
{
count = !field_count;
emoji = !field_emoji;
}
: t)
)
)
let t_of_string s =
read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s)
|