package data-encoding
Library of JSON and binary encoding combinators
Install
Dune Dependency
Authors
Maintainers
Sources
data-encoding-v0.4.tar.gz
md5=7b687e25619637d40d2bbcd2c21b00c2
sha512=65e33b1a56e9058a2e9c7f3dc18cb72c21270e0e5b9584fe856285d16e4cb8e98adac826373d4109a5e080486ec31cdd9870b402249ac5d55c7b0de6ffb68b0a
doc/src/data-encoding/binary_size.ml.html
Source file binary_size.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
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) let bool = 1 let int8 = 1 let uint8 = 1 let char = 1 let int16 = 2 let uint16 = 2 let uint30 = 4 let uint32 = 4 let uint64 = 8 let int31 = 4 let int32 = 4 let int64 = 8 let float = 8 type tag_size = [`Uint8 | `Uint16] let tag_size = function `Uint8 -> uint8 | `Uint16 -> uint16 type signed_integer = [`Int31 | `Int16 | `Int8] type unsigned_integer = [`Uint30 | `Uint16 | `Uint8] type integer = [signed_integer | unsigned_integer] let signed_range_to_size min max : [> signed_integer] = if min >= ~-128 && max <= 127 then `Int8 else if min >= ~-32_768 && max <= 32_767 then `Int16 else `Int31 (* max should be centered at zero *) let unsigned_range_to_size max : [> unsigned_integer] = assert (max >= 0); if max <= 255 then `Uint8 else if max <= 65535 then `Uint16 else `Uint30 let integer_to_size = function | `Int31 -> int31 | `Int16 -> int16 | `Int8 -> int8 | `Uint30 -> uint30 | `Uint16 -> uint16 | `Uint8 -> uint8 let max_int = function | `Uint30 | `Int31 -> (1 lsl 30) - 1 | `Int16 -> (1 lsl 15) - 1 | `Int8 -> (1 lsl 7) - 1 | `Uint16 -> (1 lsl 16) - 1 | `Uint8 -> (1 lsl 8) - 1 let min_int = function | `Uint8 | `Uint16 | `Uint30 -> 0 | `Int31 -> -(1 lsl 30) | `Int16 -> -(1 lsl 15) | `Int8 -> -(1 lsl 7) let range_to_size ~minimum ~maximum : integer = if minimum < 0 then signed_range_to_size minimum maximum else unsigned_range_to_size (maximum - minimum) let enum_size arr = unsigned_range_to_size (Array.length arr)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>