From 57df76de6441899b659e30c6a8e9d7572b85f7a0 Mon Sep 17 00:00:00 2001 From: Adelyn Breelove Date: Mon, 17 Dec 2018 13:13:10 -0700 Subject: Some abstractions --- lib/models/gen/role_j.ml | 665 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 652 insertions(+), 13 deletions(-) (limited to 'lib/models/gen/role_j.ml') diff --git a/lib/models/gen/role_j.ml b/lib/models/gen/role_j.ml index a15b6cf..4761c70 100644 --- a/lib/models/gen/role_j.ml +++ b/lib/models/gen/role_j.ml @@ -4,6 +4,18 @@ type snowflake = Snowflake_t.t type t = Role_t.t = { + id: snowflake; + name: string; + colour: int; + hoist: bool; + position: int; + permissions: int; + managed: bool; + mentionable: bool; + guild_id: snowflake +} + +type role = Role_t.role = { id: snowflake; name: string; colour: int; @@ -14,6 +26,8 @@ type t = Role_t.t = { mentionable: bool } +type role_update = Role_t.role_update = { role: role; id: snowflake } + let write_snowflake = ( Snowflake_j.write_t ) @@ -102,6 +116,15 @@ let write_t : _ -> t -> _ = ( Yojson.Safe.write_bool ) ob x.mentionable; + if !is_first then + is_first := false + else + Bi_outbuf.add_char ob ','; + Bi_outbuf.add_string ob "\"guild_id\":"; + ( + write_snowflake + ) + ob x.guild_id; Bi_outbuf.add_char ob '}'; ) let string_of_t ?(len = 1024) x = @@ -120,6 +143,7 @@ let read_t = ( let field_permissions = ref (Obj.magic (Sys.opaque_identity 0.0)) in let field_managed = ref (Obj.magic (Sys.opaque_identity 0.0)) in let field_mentionable = ref (Obj.magic (Sys.opaque_identity 0.0)) in + let field_guild_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in let bits0 = ref 0 in try Yojson.Safe.read_space p lb; @@ -177,12 +201,26 @@ let read_t = ( ) ) | 8 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( - 4 - ) - else ( - -1 - ) + match String.unsafe_get s pos with + | 'g' -> ( + if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( + 8 + ) + else ( + -1 + ) + ) + | 'p' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( + 4 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) ) | 11 -> ( match String.unsafe_get s pos with @@ -270,6 +308,13 @@ let read_t = ( ) p lb ); bits0 := !bits0 lor 0x80; + | 8 -> + field_guild_id := ( + ( + read_snowflake + ) p lb + ); + bits0 := !bits0 lor 0x100; | _ -> ( Yojson.Safe.skip_json p lb ) @@ -330,12 +375,26 @@ let read_t = ( ) ) | 8 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( - 4 - ) - else ( - -1 - ) + match String.unsafe_get s pos with + | 'g' -> ( + if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( + 8 + ) + else ( + -1 + ) + ) + | 'p' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( + 4 + ) + else ( + -1 + ) + ) + | _ -> ( + -1 + ) ) | 11 -> ( match String.unsafe_get s pos with @@ -423,6 +482,13 @@ let read_t = ( ) p lb ); bits0 := !bits0 lor 0x80; + | 8 -> + field_guild_id := ( + ( + read_snowflake + ) p lb + ); + bits0 := !bits0 lor 0x100; | _ -> ( Yojson.Safe.skip_json p lb ) @@ -430,7 +496,7 @@ let read_t = ( done; assert false; with Yojson.End_of_object -> ( - if !bits0 <> 0xff then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "name"; "colour"; "hoist"; "position"; "permissions"; "managed"; "mentionable" |]; + if !bits0 <> 0x1ff then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "name"; "colour"; "hoist"; "position"; "permissions"; "managed"; "mentionable"; "guild_id" |]; ( { id = !field_id; @@ -441,9 +507,582 @@ let read_t = ( permissions = !field_permissions; managed = !field_managed; mentionable = !field_mentionable; + guild_id = !field_guild_id; } : t) ) ) let t_of_string s = read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_role : _ -> role -> _ = ( + 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 "\"id\":"; + ( + write_snowflake + ) + ob x.id; + 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; + if !is_first then + is_first := false + else + Bi_outbuf.add_char ob ','; + Bi_outbuf.add_string ob "\"color\":"; + ( + Yojson.Safe.write_int + ) + ob x.colour; + if !is_first then + is_first := false + else + Bi_outbuf.add_char ob ','; + Bi_outbuf.add_string ob "\"hoist\":"; + ( + Yojson.Safe.write_bool + ) + ob x.hoist; + if !is_first then + is_first := false + else + Bi_outbuf.add_char ob ','; + Bi_outbuf.add_string ob "\"position\":"; + ( + Yojson.Safe.write_int + ) + ob x.position; + if !is_first then + is_first := false + else + Bi_outbuf.add_char ob ','; + Bi_outbuf.add_string ob "\"permissions\":"; + ( + Yojson.Safe.write_int + ) + ob x.permissions; + 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.managed; + if !is_first then + is_first := false + else + Bi_outbuf.add_char ob ','; + Bi_outbuf.add_string ob "\"mentionable\":"; + ( + Yojson.Safe.write_bool + ) + ob x.mentionable; + Bi_outbuf.add_char ob '}'; +) +let string_of_role ?(len = 1024) x = + let ob = Bi_outbuf.create len in + write_role ob x; + Bi_outbuf.contents ob +let read_role = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in + let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in + let field_colour = ref (Obj.magic (Sys.opaque_identity 0.0)) in + let field_hoist = ref (Obj.magic (Sys.opaque_identity 0.0)) in + let field_position = ref (Obj.magic (Sys.opaque_identity 0.0)) in + let field_permissions = ref (Obj.magic (Sys.opaque_identity 0.0)) in + let field_managed = ref (Obj.magic (Sys.opaque_identity 0.0)) in + let field_mentionable = 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"; + match len with + | 2 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( + 0 + ) + else ( + -1 + ) + ) + | 4 -> ( + if String.unsafe_get s pos = 'n' && 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 + ) + ) + | 5 -> ( + match String.unsafe_get s pos with + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'r' then ( + 2 + ) + else ( + -1 + ) + ) + | 'h' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 't' then ( + 3 + ) + else ( + -1 + ) + ) + | _ -> ( + -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 ( + 6 + ) + else ( + -1 + ) + ) + | 8 -> ( + if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( + 4 + ) + else ( + -1 + ) + ) + | 11 -> ( + match String.unsafe_get s pos with + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'b' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' then ( + 7 + ) + else ( + -1 + ) + ) + | 'p' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 's' then ( + 5 + ) + else ( + -1 + ) + ) + | _ -> ( + -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 -> + field_id := ( + ( + read_snowflake + ) p lb + ); + bits0 := !bits0 lor 0x1; + | 1 -> + field_name := ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ); + bits0 := !bits0 lor 0x2; + | 2 -> + field_colour := ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ); + bits0 := !bits0 lor 0x4; + | 3 -> + field_hoist := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + bits0 := !bits0 lor 0x8; + | 4 -> + field_position := ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ); + bits0 := !bits0 lor 0x10; + | 5 -> + field_permissions := ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ); + bits0 := !bits0 lor 0x20; + | 6 -> + field_managed := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + bits0 := !bits0 lor 0x40; + | 7 -> + field_mentionable := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + bits0 := !bits0 lor 0x80; + | _ -> ( + 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 -> ( + if String.unsafe_get s pos = 'n' && 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 + ) + ) + | 5 -> ( + match String.unsafe_get s pos with + | 'c' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'r' then ( + 2 + ) + else ( + -1 + ) + ) + | 'h' -> ( + if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 't' then ( + 3 + ) + else ( + -1 + ) + ) + | _ -> ( + -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 ( + 6 + ) + else ( + -1 + ) + ) + | 8 -> ( + if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( + 4 + ) + else ( + -1 + ) + ) + | 11 -> ( + match String.unsafe_get s pos with + | 'm' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'b' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' then ( + 7 + ) + else ( + -1 + ) + ) + | 'p' -> ( + if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 's' then ( + 5 + ) + else ( + -1 + ) + ) + | _ -> ( + -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 -> + field_id := ( + ( + read_snowflake + ) p lb + ); + bits0 := !bits0 lor 0x1; + | 1 -> + field_name := ( + ( + Atdgen_runtime.Oj_run.read_string + ) p lb + ); + bits0 := !bits0 lor 0x2; + | 2 -> + field_colour := ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ); + bits0 := !bits0 lor 0x4; + | 3 -> + field_hoist := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + bits0 := !bits0 lor 0x8; + | 4 -> + field_position := ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ); + bits0 := !bits0 lor 0x10; + | 5 -> + field_permissions := ( + ( + Atdgen_runtime.Oj_run.read_int + ) p lb + ); + bits0 := !bits0 lor 0x20; + | 6 -> + field_managed := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + bits0 := !bits0 lor 0x40; + | 7 -> + field_mentionable := ( + ( + Atdgen_runtime.Oj_run.read_bool + ) p lb + ); + bits0 := !bits0 lor 0x80; + | _ -> ( + Yojson.Safe.skip_json p lb + ) + ); + done; + assert false; + with Yojson.End_of_object -> ( + if !bits0 <> 0xff then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "name"; "colour"; "hoist"; "position"; "permissions"; "managed"; "mentionable" |]; + ( + { + id = !field_id; + name = !field_name; + colour = !field_colour; + hoist = !field_hoist; + position = !field_position; + permissions = !field_permissions; + managed = !field_managed; + mentionable = !field_mentionable; + } + : role) + ) +) +let role_of_string s = + read_role (Yojson.Safe.init_lexer ()) (Lexing.from_string s) +let write_role_update : _ -> role_update -> _ = ( + 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 "\"role\":"; + ( + write_role + ) + ob x.role; + if !is_first then + is_first := false + else + Bi_outbuf.add_char ob ','; + Bi_outbuf.add_string ob "\"id\":"; + ( + write_snowflake + ) + ob x.id; + Bi_outbuf.add_char ob '}'; +) +let string_of_role_update ?(len = 1024) x = + let ob = Bi_outbuf.create len in + write_role_update ob x; + Bi_outbuf.contents ob +let read_role_update = ( + fun p lb -> + Yojson.Safe.read_space p lb; + Yojson.Safe.read_lcurl p lb; + let field_role = ref (Obj.magic (Sys.opaque_identity 0.0)) in + let field_id = 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"; + match len with + | 2 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( + 1 + ) + else ( + -1 + ) + ) + | 4 -> ( + 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' then ( + 0 + ) + 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 -> + field_role := ( + ( + read_role + ) p lb + ); + bits0 := !bits0 lor 0x1; + | 1 -> + field_id := ( + ( + read_snowflake + ) 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"; + match len with + | 2 -> ( + if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( + 1 + ) + else ( + -1 + ) + ) + | 4 -> ( + 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' then ( + 0 + ) + 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 -> + field_role := ( + ( + read_role + ) p lb + ); + bits0 := !bits0 lor 0x1; + | 1 -> + field_id := ( + ( + read_snowflake + ) 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 |] [| "role"; "id" |]; + ( + { + role = !field_role; + id = !field_id; + } + : role_update) + ) +) +let role_update_of_string s = + read_role_update (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -- cgit v1.2.3 From 1a73007b3aaa17940173eaff1eb4f6703fd9ec0c Mon Sep 17 00:00:00 2001 From: Adelyn Breelove Date: Wed, 19 Dec 2018 13:44:04 -0700 Subject: Re-arrange autogen serialization files and incorporate into dune file --- lib/models/gen/role_j.ml | 1088 ---------------------------------------------- 1 file changed, 1088 deletions(-) delete mode 100644 lib/models/gen/role_j.ml (limited to 'lib/models/gen/role_j.ml') diff --git a/lib/models/gen/role_j.ml b/lib/models/gen/role_j.ml deleted file mode 100644 index 4761c70..0000000 --- a/lib/models/gen/role_j.ml +++ /dev/null @@ -1,1088 +0,0 @@ -(* Auto-generated from "role.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = Role_t.t = { - id: snowflake; - name: string; - colour: int; - hoist: bool; - position: int; - permissions: int; - managed: bool; - mentionable: bool; - guild_id: snowflake -} - -type role = Role_t.role = { - id: snowflake; - name: string; - colour: int; - hoist: bool; - position: int; - permissions: int; - managed: bool; - mentionable: bool -} - -type role_update = Role_t.role_update = { role: role; id: snowflake } - -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_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 "\"id\":"; - ( - write_snowflake - ) - ob x.id; - 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; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"color\":"; - ( - Yojson.Safe.write_int - ) - ob x.colour; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"hoist\":"; - ( - Yojson.Safe.write_bool - ) - ob x.hoist; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"position\":"; - ( - Yojson.Safe.write_int - ) - ob x.position; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"permissions\":"; - ( - Yojson.Safe.write_int - ) - ob x.permissions; - 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.managed; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"mentionable\":"; - ( - Yojson.Safe.write_bool - ) - ob x.mentionable; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"guild_id\":"; - ( - write_snowflake - ) - ob x.guild_id; - 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 (Obj.magic (Sys.opaque_identity 0.0)) in - let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_colour = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_hoist = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_position = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_permissions = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_managed = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_mentionable = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_guild_id = 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"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'n' && 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 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'r' then ( - 2 - ) - else ( - -1 - ) - ) - | 'h' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 't' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -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 ( - 6 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'g' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 8 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( - 4 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'b' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' then ( - 7 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 's' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -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 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_colour := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - field_hoist := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 4 -> - field_position := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 5 -> - field_permissions := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x20; - | 6 -> - field_managed := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x40; - | 7 -> - field_mentionable := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x80; - | 8 -> - field_guild_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x100; - | _ -> ( - 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 -> ( - if String.unsafe_get s pos = 'n' && 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 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'r' then ( - 2 - ) - else ( - -1 - ) - ) - | 'h' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 't' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -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 ( - 6 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'g' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 8 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( - 4 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'b' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' then ( - 7 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 's' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -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 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_colour := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - field_hoist := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 4 -> - field_position := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 5 -> - field_permissions := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x20; - | 6 -> - field_managed := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x40; - | 7 -> - field_mentionable := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x80; - | 8 -> - field_guild_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x100; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x1ff then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "name"; "colour"; "hoist"; "position"; "permissions"; "managed"; "mentionable"; "guild_id" |]; - ( - { - id = !field_id; - name = !field_name; - colour = !field_colour; - hoist = !field_hoist; - position = !field_position; - permissions = !field_permissions; - managed = !field_managed; - mentionable = !field_mentionable; - guild_id = !field_guild_id; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_role : _ -> role -> _ = ( - 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 "\"id\":"; - ( - write_snowflake - ) - ob x.id; - 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; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"color\":"; - ( - Yojson.Safe.write_int - ) - ob x.colour; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"hoist\":"; - ( - Yojson.Safe.write_bool - ) - ob x.hoist; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"position\":"; - ( - Yojson.Safe.write_int - ) - ob x.position; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"permissions\":"; - ( - Yojson.Safe.write_int - ) - ob x.permissions; - 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.managed; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"mentionable\":"; - ( - Yojson.Safe.write_bool - ) - ob x.mentionable; - Bi_outbuf.add_char ob '}'; -) -let string_of_role ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_role ob x; - Bi_outbuf.contents ob -let read_role = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_colour = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_hoist = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_position = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_permissions = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_managed = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_mentionable = 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"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'n' && 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 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'r' then ( - 2 - ) - else ( - -1 - ) - ) - | 'h' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 't' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -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 ( - 6 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( - 4 - ) - else ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'b' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' then ( - 7 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 's' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -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 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_colour := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - field_hoist := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 4 -> - field_position := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 5 -> - field_permissions := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x20; - | 6 -> - field_managed := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x40; - | 7 -> - field_mentionable := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x80; - | _ -> ( - 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 -> ( - if String.unsafe_get s pos = 'n' && 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 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'r' then ( - 2 - ) - else ( - -1 - ) - ) - | 'h' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 't' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -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 ( - 6 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( - 4 - ) - else ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'b' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' then ( - 7 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 's' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -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 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_colour := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - field_hoist := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 4 -> - field_position := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 5 -> - field_permissions := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x20; - | 6 -> - field_managed := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x40; - | 7 -> - field_mentionable := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x80; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0xff then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "name"; "colour"; "hoist"; "position"; "permissions"; "managed"; "mentionable" |]; - ( - { - id = !field_id; - name = !field_name; - colour = !field_colour; - hoist = !field_hoist; - position = !field_position; - permissions = !field_permissions; - managed = !field_managed; - mentionable = !field_mentionable; - } - : role) - ) -) -let role_of_string s = - read_role (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_role_update : _ -> role_update -> _ = ( - 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 "\"role\":"; - ( - write_role - ) - ob x.role; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"id\":"; - ( - write_snowflake - ) - ob x.id; - Bi_outbuf.add_char ob '}'; -) -let string_of_role_update ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_role_update ob x; - Bi_outbuf.contents ob -let read_role_update = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_role = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_id = 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"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 1 - ) - else ( - -1 - ) - ) - | 4 -> ( - 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' then ( - 0 - ) - 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 -> - field_role := ( - ( - read_role - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_id := ( - ( - read_snowflake - ) 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"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 1 - ) - else ( - -1 - ) - ) - | 4 -> ( - 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' then ( - 0 - ) - 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 -> - field_role := ( - ( - read_role - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_id := ( - ( - read_snowflake - ) 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 |] [| "role"; "id" |]; - ( - { - role = !field_role; - id = !field_id; - } - : role_update) - ) -) -let role_update_of_string s = - read_role_update (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -- cgit v1.2.3