package mgit
Build not yet checked sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Git in OCaml
Install
dune-project
Dependency
Authors
Maintainers
Sources
mgit-0.1.0.tbz
sha256=6fad812ce53e69e045c4d53d958fc0f12c13900841348dd37f0ba6dd0db2ba8d
sha512=3c2427bc9ee42748aa99540582125aea989dca574493ef46cae70d67ab005c517f079c6c537507b3cb53544811864d52d30df22993b7c297f6a6521f6484ff82
doc/src/mgit.mem/mgit_mem.ml.html
Source file mgit_mem.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 77module Object = Mgit_object type t = { objects: (string, Carton.Kind.t * string) Hashtbl.t ; references: (string * Carton.Uid.t) list ; prerequisites: (Carton.Uid.t * string option) list ; tmp: Buffer.t } let make () = { objects= Hashtbl.create 0x7ff ; references= [] ; prerequisites= [] ; tmp= Buffer.create 0x7ff } let references t = t.references let prerequisites t = t.prerequisites let reference t name = List.assoc_opt name t.references let is_empty t = t.references = [] let read t (uid : Carton.Uid.t) = Hashtbl.find_opt t.objects (uid :> string) let kind t uid = Option.map fst (read t uid) let length t uid = Option.map (fun (_, payload) -> String.length payload) (read t uid) let value t uid = let fn (kind, payload) = Carton.Value.of_string ~kind payload in Option.map fn (read t uid) let uids t = Hashtbl.to_seq_keys t.objects |> Seq.map Carton.Uid.unsafe_of_string |> List.of_seq let publish t ~references ~prerequisites objects = let tbl = Hashtbl.create (List.length objects) in let fn ((uid : Carton.Uid.t), kind, payload) = Hashtbl.replace tbl (uid :> string) (kind, payload) in List.iter fn objects; { t with objects= tbl; references; prerequisites } module Tmp = struct type extern = Carton.Uid.t -> (Carton.Kind.t * Bstr.t) option let sink t = let init () = Buffer.clear t.tmp; t.tmp in let push buf str = Buffer.add_string buf str; buf in Flux.Sink { init; push; full= Fun.const false; stop= ignore } let seq t ~len = let rec go off () = if off >= len then Seq.Nil else let n = Int.min 0x7ff (len - off) in Seq.Cons (Buffer.sub t.tmp off n, go (off + n)) in go 0 let map bstr ~pos len = let max = Bstr.length bstr in if pos < 0 || pos >= max then Bstr.empty else Bstr.sub bstr ~off:pos ~len:(Int.min len (max - pos)) let carton ?(extern = Fun.const None) t ~len = let bstr = Bstr.of_string (Buffer.sub t.tmp 0 len) in let index (uid : Carton.Uid.t) = match extern uid with | Some (kind, bstr) -> Carton.Extern (kind, bstr) | None -> raise Not_found in Carton.make ~map bstr ~z:(Bstr.create 0x7ff) ~allocate:(fun bits -> De.make_window ~bits) ~ref_length:Object.ref_length index end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>