@@ -5,6 +5,8 @@ module T = Ffi_generated.Types
55type value =
66 [ `Null
77 | `Int of int
8+ | `Int64 of Int64 .t
9+ | `UInt64 of Unsigned.UInt64 .t
810 | `Float of float
911 | `String of string
1012 | `Bytes of bytes
@@ -84,8 +86,8 @@ let convert field typ unsigned =
8486 | `Short , false -> `Int (UInt. to_int (cast_to uint field))
8587 | (`Int24 | `Long ), true -> `Int (UInt32. to_int (cast_to uint32_t field))
8688 | (`Int24 | `Long ), false -> `Int (Int32. to_int (cast_to int32_t field))
87- | `Long_long , true -> `Int ( UInt64. to_int (cast_to uint64_t field) )
88- | `Long_long , false -> `Int ( Int64. to_int (cast_to int64_t field) )
89+ | `Long_long , true -> `UInt64 (cast_to uint64_t field)
90+ | `Long_long , false -> `Int64 (cast_to int64_t field)
8991 | `Float , _ -> `Float (cast_to float field)
9092 | `Double , _ -> `Float (cast_to double field)
9193 | #to_string , _ -> `String (Bytes. to_string (to_bytes field))
@@ -105,8 +107,21 @@ let err field ~info =
105107let int field =
106108 match value field with
107109 | `Int i -> i
110+ | `Int64 i -> Int64. to_int i
111+ | `UInt64 i -> Unsigned.UInt64. to_int i
108112 | _ -> err field ~info: " an integer"
109113
114+ let int64 field =
115+ match value field with
116+ | `Int i -> Int64. of_int i
117+ | `Int64 i -> i
118+ | _ -> err field ~info: " a 64-bit integer"
119+
120+ let uint64 field =
121+ match value field with
122+ | `UInt64 i -> i
123+ | _ -> err field ~info: " a 64-bit unsigned integer"
124+
110125let float field =
111126 match value field with
112127 | `Float x -> x
@@ -130,9 +145,24 @@ let time field =
130145let int_opt field =
131146 match value field with
132147 | `Int i -> Some i
148+ | `Int64 i -> Some (Int64. to_int i)
149+ | `UInt64 i -> Some (Unsigned.UInt64. to_int i)
133150 | `Null -> None
134151 | _ -> err field ~info: " a nullable integer"
135152
153+ let int64_opt field =
154+ match value field with
155+ | `Int i -> Some (Int64. of_int i)
156+ | `Int64 i -> Some i
157+ | `Null -> None
158+ | _ -> err field ~info: " a nullable 64-bit integer"
159+
160+ let uint64_opt field =
161+ match value field with
162+ | `UInt64 i -> Some i
163+ | `Null -> None
164+ | _ -> err field ~info: " a nullable 64-bit unsigned integer"
165+
136166let float_opt field =
137167 match value field with
138168 | `Float x -> Some x
0 commit comments