(* Auto-generated from "emoji.atd" *) [@@@ocaml.warning "-27-32-35-39"] type user = User_t.t type snowflake = Snowflake_t.t type t = Emoji_t.t = { id: snowflake option; name: string; roles: snowflake list option; user: user option; require_colons: bool option; managed: bool option; animated: bool option } let write_user = ( User_j.write_t ) let string_of_user ?(len = 1024) x = let ob = Bi_outbuf.create len in write_user ob x; Bi_outbuf.contents ob let read_user = ( User_j.read_t ) let user_of_string s = read_user (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_snowflake = ( Snowflake_j.write_t ) let string_of_snowflake ?(len = 1024) x = let ob = Bi_outbuf.create len in write_snowflake ob x; Bi_outbuf.contents ob let read_snowflake = ( Snowflake_j.read_t ) let snowflake_of_string s = read_snowflake (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__5 = ( Atdgen_runtime.Oj_run.write_option ( Yojson.Safe.write_bool ) ) let string_of__5 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__5 ob x; Bi_outbuf.contents ob let read__5 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( Atdgen_runtime.Oj_run.read_bool ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( Atdgen_runtime.Oj_run.read_bool ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _5_of_string s = read__5 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__4 = ( Atdgen_runtime.Oj_run.write_option ( write_user ) ) let string_of__4 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__4 ob x; Bi_outbuf.contents ob let read__4 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( read_user ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( read_user ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _4_of_string s = read__4 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__2 = ( Atdgen_runtime.Oj_run.write_list ( write_snowflake ) ) let string_of__2 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__2 ob x; Bi_outbuf.contents ob let read__2 = ( Atdgen_runtime.Oj_run.read_list ( read_snowflake ) ) let _2_of_string s = read__2 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__3 = ( Atdgen_runtime.Oj_run.write_option ( write__2 ) ) let string_of__3 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__3 ob x; Bi_outbuf.contents ob let read__3 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( read__2 ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( read__2 ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _3_of_string s = read__3 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__1 = ( Atdgen_runtime.Oj_run.write_option ( write_snowflake ) ) let string_of__1 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__1 ob x; Bi_outbuf.contents ob let read__1 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( read_snowflake ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( read_snowflake ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _1_of_string s = read__1 (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 (match x.id with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"id\":"; ( write_snowflake ) ob x; ); if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"name\":"; ( Yojson.Safe.write_string ) ob x.name; (match x.roles with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"roles\":"; ( write__2 ) ob x; ); (match x.user with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"user\":"; ( write_user ) ob x; ); (match x.require_colons with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"require_colons\":"; ( Yojson.Safe.write_bool ) ob x; ); (match x.managed with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"managed\":"; ( Yojson.Safe.write_bool ) ob x; ); (match x.animated with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"animated\":"; ( Yojson.Safe.write_bool ) ob x; ); 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_id = ref (None) in let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in let field_roles = ref (None) in let field_user = ref (None) in let field_require_colons = ref (None) in let field_managed = ref (None) in let field_animated = ref (None) 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"; match len with | 2 -> ( if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( 0 ) else ( -1 ) ) | 4 -> ( match String.unsafe_get s pos with | 'n' -> ( if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( 1 ) else ( -1 ) ) | 'u' -> ( if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' then ( 3 ) else ( -1 ) ) | _ -> ( -1 ) ) | 5 -> ( if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( 2 ) else ( -1 ) ) | 7 -> ( if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'd' then ( 5 ) else ( -1 ) ) | 8 -> ( if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'd' then ( 6 ) else ( -1 ) ) | 14 -> ( if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'q' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 's' then ( 4 ) else ( -1 ) ) | _ -> ( -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 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_id := ( Some ( ( read_snowflake ) p lb ) ); ) | 1 -> field_name := ( ( Atdgen_runtime.Oj_run.read_string ) p lb ); bits0 := !bits0 lor 0x1; | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_roles := ( Some ( ( read__2 ) p lb ) ); ) | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_user := ( Some ( ( read_user ) p lb ) ); ) | 4 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_require_colons := ( Some ( ( Atdgen_runtime.Oj_run.read_bool ) p lb ) ); ) | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_managed := ( Some ( ( Atdgen_runtime.Oj_run.read_bool ) p lb ) ); ) | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_animated := ( Some ( ( Atdgen_runtime.Oj_run.read_bool ) p lb ) ); ) | _ -> ( 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"; match len with | 2 -> ( if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( 0 ) else ( -1 ) ) | 4 -> ( match String.unsafe_get s pos with | 'n' -> ( if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( 1 ) else ( -1 ) ) | 'u' -> ( if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' then ( 3 ) else ( -1 ) ) | _ -> ( -1 ) ) | 5 -> ( if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( 2 ) else ( -1 ) ) | 7 -> ( if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'd' then ( 5 ) else ( -1 ) ) | 8 -> ( if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'd' then ( 6 ) else ( -1 ) ) | 14 -> ( if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'q' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 's' then ( 4 ) else ( -1 ) ) | _ -> ( -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 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_id := ( Some ( ( read_snowflake ) p lb ) ); ) | 1 -> field_name := ( ( Atdgen_runtime.Oj_run.read_string ) p lb ); bits0 := !bits0 lor 0x1; | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_roles := ( Some ( ( read__2 ) p lb ) ); ) | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_user := ( Some ( ( read_user ) p lb ) ); ) | 4 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_require_colons := ( Some ( ( Atdgen_runtime.Oj_run.read_bool ) p lb ) ); ) | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_managed := ( Some ( ( Atdgen_runtime.Oj_run.read_bool ) p lb ) ); ) | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_animated := ( Some ( ( Atdgen_runtime.Oj_run.read_bool ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); done; assert false; with Yojson.End_of_object -> ( if !bits0 <> 0x1 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "name" |]; ( { id = !field_id; name = !field_name; roles = !field_roles; user = !field_user; require_colons = !field_require_colons; managed = !field_managed; animated = !field_animated; } : t) ) ) let t_of_string s = read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s)