package atdgen-runtime
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Runtime library for code generated by atdgen
Install
dune-project
Dependency
Authors
-
MMartin Jambon <martin@mjambon.com>
-
MMartin Jambon <martin@r2c.dev>
-
RRudi Grinberg <rudi.grinberg@gmail.com>
-
MMartin Jambon <github@mjambon.com>
-
AAlexandre Bourquelot <alexandre.bourquelot@ahrefs.com>
-
Ooleksiy <oleksiy.golovko@ahrefs.com>
-
IIvan Jager <aij+git@mrph.org>
-
MMartin Jambon <martin@semgrep.com>
-
GGregoire Lionnet <gregoire.lionnet@ahrefs.com>
-
SSebastien Mondet <sebastien.mondet@ahrefs.com>
-
DDavid Sheets <sheets@alum.mit.edu>
-
RRudi Grinberg <me@rgrinberg.com>
-
MMartin Jambon <martin@esper.com>
-
RRytis Jonynas <rytis.jonynas@ahrefs.com>
-
JJeff Meister <nanaki@gmail.com>
-
RRaman Varabets <roman.vorobets@gmail.com>
-
CCarmelo Piccione <carmelo.piccione@gmail.com>
-
LLouis <louis.roche@ahrefs.com>
-
CCaio Wakamatsu <caio.wakamatsu@ahrefs.com>
-
MMarek Kubica <marek@tarides.com>
-
DDaniel Weil <danweil68@gmail.com>
-
EEgor Chemokhonenko <egor.chemohonenko@ahrefs.com>
-
Gabriel Scherer
-
JJavier Chavarri <javier.chavarri@gmail.com>
-
LLouis Roché (Ahrefs) <louis.roche@ahrefs.com>
-
MMatthew McQuaid <matthew@returntocorp.com>
-
RRaman Varabets <raman+git@ahrefs.com>
-
Kkoonwen <koonwen@gmail.com>
-
Ttzm <frank@boldsolutions.de>
-
MMathieu Baudet <mathieubaudet@fb.com>
-
OOleksiy Golovko <alexei.golovko@gmail.com>
-
RRauan Mayemir <rauan@mayemir.io>
-
SSeb Mondet <seb@mondet.org>
-
AAlexandre Bourquelot <alexandre.bourquelot@gmail.com>
-
CCarmelo Piccione <cep1@solvuu.com>
-
HHyeseong Kim <hey@hyeseong.kim>
-
JJohn Billings <john@monkeynut.org>
-
LLouis Roché <louis@louisroche.net>
-
MMathieu Barbin <mathieu.barbin@gmail.com>
-
ZZach Yannes <zach@returntocorp.com>
-
AAntonin Décimo <antonin@tarides.com>
-
BBrendan Long <self@brendanlong.com>
-
CChris Yocum <cyocum@gmail.com>
-
KKate <kit.ty.kate@disroot.org>
-
LLouis Roché <louis.roche@ahrefs.com>
-
PPavel Antoshkin <pavel.antoshkin@ahrefs.com>
-
PPierre Boutillier <pierre.boutillier@laposte.net>
-
SShon Feder <shon.feder@key.me>
-
Mmetanivek <metanivek@gmail.com>
-
Ssebastiantoh <sebas.tsj.98@gmail.com>
-
AAnurag Soni <anuragsoni.13@gmail.com>
-
AArjun Ravi Narayan <arjunravinarayan@gmail.com>
-
AAsya-kawai <kawai-toshiki@aintek.xyz>
-
CChristophe Troestler <christophe.Troestler@umons.ac.be>
-
CCorentin Leruth <corentin.leruth@gmail.com>
-
Damien Doligez
-
DDaniel M <dan.mntg@gmail.com>
-
DDing Xiang Fei <dingxiangfei2009@protonmail.ch>
-
EEnrico Tassi <Enrico.Tassi@Inria.fr>
-
FFrançois Pottier <francois.pottier@inria.fr>
-
JJavier Chávarri <javier.chavarri@gmail.com>
-
JJonas Bergler <jonas@bergler.name>
-
KKate <kit-ty-kate@exn.st>
-
KKoon Wen Lee <koonwen@gmail.com>
-
LLouis <mail+github@louisroche.net>
-
LLouis Roché <louis@cryptosense.com>
-
SStephane Legrand <slegrand45@gmail.com>
-
VVincent Bernardoff <vb@luminar.eu.org>
-
ZZach <zachyannes@gmail.com>
-
Hhaoyang <haoyang@esper.co>
-
Ppmundkur <prashanth.mundkur@gmail.com>
-
Rrr0gi <igor@ahrefs.com>
-
Yygrek <ygrek@autistici.org>
Maintainers
Sources
atd-3.0.1.tbz
sha256=03aeae4565a32d8bb68ac8514af5efc7800b1619c2973941ca7138b12b344884
sha512=412ce655772ddde30a9e22b4d00b263b3edd7241357f3f8a6d13ec6835c5a147a3033740634f8abbc5e32a830f56939cb24c5d3c4b531e55b76d4d20fefe2a64
doc/src/atdgen-runtime/oj_run.ml.html
Source file oj_run.ml
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281(* Runtime library for JSON *) open Printf type 'a write = Buffer.t -> 'a -> unit exception Error of string (* Error messages *) let error s = raise (Error s) let error_with_line p s = let s2 = match p.Yojson.Lexer_state.fname with Some f -> sprintf "File %s, line %i:\n%s" f p.Yojson.Lexer_state.lnum s | None -> sprintf "Line %i:\n%s" p.Yojson.Lexer_state.lnum s in raise (Error s2) let list_iter f sep x l = let rec aux f sep x = function [] -> () | y :: l -> sep x; f x y; aux f sep x l in match l with [] -> () | y :: l -> f x y; aux f sep x l let array_iter f sep x a = let n = Array.length a in if n > 0 then ( f x (Array.unsafe_get a 0); for i = 1 to n - 1 do sep x; f x (Array.unsafe_get a i) done ) let write_comma ob = Buffer.add_char ob ',' let write_list write_item ob l = Buffer.add_char ob '['; list_iter write_item write_comma ob l; Buffer.add_char ob ']' let write_array write_item ob a = Buffer.add_char ob '['; array_iter write_item write_comma ob a; Buffer.add_char ob ']' let write_assoc_list write_key write_item ob l = Buffer.add_char ob '{'; list_iter ( fun ob (k, v) -> write_key ob k; Buffer.add_char ob ':'; write_item ob v ) write_comma ob l; Buffer.add_char ob '}' let write_assoc_array write_key write_item ob l = Buffer.add_char ob '{'; array_iter ( fun ob (k, v) -> write_key ob k; Buffer.add_char ob ':'; write_item ob v ) write_comma ob l; Buffer.add_char ob '}' let write_option write_item ob = function None -> Buffer.add_string ob "<\"None\">" | Some x -> Buffer.add_string ob "<\"Some\":"; write_item ob x; Buffer.add_string ob ">" let write_std_option write_item ob = function None -> Buffer.add_string ob "\"None\"" | Some x -> Buffer.add_string ob "[\"Some\","; write_item ob x; Buffer.add_string ob "]" let write_nullable write_item ob = function None -> Buffer.add_string ob "null" | Some x -> write_item ob x let write_int_as_string ob x = Buffer.add_char ob '"'; Yojson.Safe.write_int ob x; Buffer.add_char ob '"' let write_int8 ob x = Yojson.Safe.write_int ob (int_of_char x) let write_int8_as_string ob x = Buffer.add_char ob '"'; write_int8 ob x; Buffer.add_char ob '"' let write_int32 ob x = Buffer.add_string ob (Int32.to_string x) let write_int32_as_string ob x = Buffer.add_char ob '"'; write_int32 ob x; Buffer.add_char ob '"' let write_int64 ob x = Buffer.add_string ob (Int64.to_string x) let write_int64_as_string ob x = Buffer.add_char ob '"'; write_int64 ob x; Buffer.add_char ob '"' let min_float = float min_int let max_float = float max_int let write_float_as_int ob x = if x >= min_float && x <= max_float then Yojson.Safe.write_int ob (int_of_float (if x < 0. then x -. 0.5 else x +. 0.5)) else match classify_float x with FP_normal | FP_subnormal | FP_zero -> Buffer.add_string ob (Printf.sprintf "%.0f" x) | FP_infinite -> error "Cannot convert inf or -inf into a JSON int" | FP_nan -> error "Cannot convert NaN into a JSON int" let write_float_as_int_string ob x = Buffer.add_char ob '"'; write_float_as_int ob x; Buffer.add_char ob '"' type 'a read = Yojson.lexer_state -> Lexing.lexbuf -> 'a let read_null p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_null p lb let read_bool p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_bool p lb let read_int p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_int p lb let read_int8 p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_int8 p lb let read_int32 p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_int32 p lb let read_int64 p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_int64 p lb let read_number p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_number p lb let read_string p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_string p lb let read_json p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_json p lb let read_list read_item p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_list read_item p lb let read_array read_item p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_array read_item p lb let read_assoc_list_rev read_key read_item p lb = Yojson.Safe.read_space p lb; let read acc k p lb = (k, read_item p lb) :: acc in Yojson.Safe.read_abstract_fields read_key read [] p lb let read_assoc_list read_key read_item p lb = List.rev (read_assoc_list_rev read_key read_item p lb) let array_of_rev_list l = match l with [] -> [| |] | x :: tl -> let len = List.length l in let a = Array.make len x in let r = ref tl in for i = len - 2 downto 0 do a.(i) <- List.hd !r; r := List.tl !r done; a let read_assoc_array read_key read_item p lb = array_of_rev_list (read_assoc_list_rev read_key read_item p lb) let read_until_field_value p lb = Yojson.Safe.read_space p lb; Yojson.Safe.read_colon p lb; Yojson.Safe.read_space p lb let missing_tuple_fields p len req_fields = let missing = List.fold_right ( fun i acc -> if i >= len then i :: acc else acc ) req_fields [] in error_with_line p (sprintf "Missing tuple field%s %s" (if List.length missing > 1 then "s" else "") (String.concat ", " (List.map string_of_int missing))) let missing_field p field_name = error_with_line p (sprintf "Missing record field %s" field_name) let missing_fields p bit_fields field_names = let acc = ref [] in for z = Array.length field_names - 1 downto 0 do let i = z / 31 in let j = z mod 31 in if bit_fields.(i) land (1 lsl j) = 0 then acc := field_names.(z) :: !acc done; error_with_line p (sprintf "Missing record field%s %s" (if List.length !acc > 1 then "s" else "") (String.concat ", " !acc)) let invalid_variant_tag p s = error_with_line p (sprintf "Unsupported variant %S" s) let read_with_adapter normalize reader p lb = let ast = Yojson.Safe.read_json p lb in let ast' = normalize ast in let s' = Yojson.Safe.to_string ast' in let lb' = Lexing.from_string s' in reader p lb' let write_with_adapter restore writer ob x = let ob_tmp = Buffer.create 1024 in writer ob_tmp x; let s_tmp = Buffer.contents ob_tmp in let ast = Yojson.Safe.from_string s_tmp in let ast' = restore ast in Yojson.Safe.to_buffer ob ast' (* Checking at runtime that our assumptions on unspecified compiler behavior still hold. TODO: what are these assumptions and which component makes them? *) type t = { _a : int option; _b : int; } (* This must be a test for the type checker since the function isn't used anywhere. *) let _test () = { { _a = None; _b = Array.length Sys.argv } with _a = None }
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>