Source file g.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
module CI = Cstubs_internals
external mmdb_stub_1_MMDB_open : _ CI.fatptr -> int -> _ CI.fatptr -> int
= "mmdb_stub_1_MMDB_open"
external mmdb_stub_2_MMDB_close : _ CI.fatptr -> unit
= "mmdb_stub_2_MMDB_close"
external mmdb_stub_3_MMDB_lookup_string
: _ CI.fatptr -> _ CI.fatptr -> _ CI.fatptr -> _ CI.fatptr ->
CI.managed_buffer = "mmdb_stub_3_MMDB_lookup_string"
external mmdb_stub_4_MMDB_aget_value
: _ CI.fatptr -> _ CI.fatptr -> _ CI.fatptr -> int
= "mmdb_stub_4_MMDB_aget_value"
external mmdb_stub_5_MMDB_strerror : int -> CI.voidp
= "mmdb_stub_5_MMDB_strerror"
external mmdb_stub_6_MMDB_lib_version : unit -> CI.voidp
= "mmdb_stub_6_MMDB_lib_version"
external mmdb_stub_7_mmdb_ml_sizeof_mmdb_s : unit -> Unsigned.size_t
= "mmdb_stub_7_mmdb_ml_sizeof_mmdb_s"
external mmdb_stub_8_mmdb_ml_alignof_mmdb_s : unit -> Unsigned.size_t
= "mmdb_stub_8_mmdb_ml_alignof_mmdb_s"
external mmdb_stub_9_mmdb_ml_sizeof_mmdb_entry_data_s
: unit -> Unsigned.size_t = "mmdb_stub_9_mmdb_ml_sizeof_mmdb_entry_data_s"
external mmdb_stub_10_mmdb_ml_alignof_mmdb_entry_data_s
: unit -> Unsigned.size_t
= "mmdb_stub_10_mmdb_ml_alignof_mmdb_entry_data_s"
external mmdb_stub_11_mmdb_ml_language_count : _ CI.fatptr -> Unsigned.size_t
= "mmdb_stub_11_mmdb_ml_language_count"
external mmdb_stub_12_mmdb_ml_language_names : _ CI.fatptr -> CI.voidp
= "mmdb_stub_12_mmdb_ml_language_names"
external mmdb_stub_13_mmdb_ml_binary_format_major_version
: _ CI.fatptr -> Unsigned.uint16
= "mmdb_stub_13_mmdb_ml_binary_format_major_version"
external mmdb_stub_14_mmdb_ml_binary_format_minor_version
: _ CI.fatptr -> Unsigned.uint16
= "mmdb_stub_14_mmdb_ml_binary_format_minor_version"
external mmdb_stub_15_mmdb_ml_get_entry_data_has_data : _ CI.fatptr -> bool
= "mmdb_stub_15_mmdb_ml_get_entry_data_has_data"
external mmdb_stub_16_mmdb_ml_get_entry_data_type
: _ CI.fatptr -> Unsigned.uint32
= "mmdb_stub_16_mmdb_ml_get_entry_data_type"
external mmdb_stub_17_mmdb_ml_get_entry_data_size
: _ CI.fatptr -> Unsigned.uint32
= "mmdb_stub_17_mmdb_ml_get_entry_data_size"
external mmdb_stub_18_mmdb_ml_get_entry_data_utf8_string_value
: _ CI.fatptr -> CI.voidp
= "mmdb_stub_18_mmdb_ml_get_entry_data_utf8_string_value"
external mmdb_stub_19_mmdb_ml_get_entry_data_double_value
: _ CI.fatptr -> float = "mmdb_stub_19_mmdb_ml_get_entry_data_double_value"
external mmdb_stub_20_mmdb_ml_get_entry_data_bytes_value
: _ CI.fatptr -> CI.voidp
= "mmdb_stub_20_mmdb_ml_get_entry_data_bytes_value"
external mmdb_stub_21_mmdb_ml_get_entry_data_uint16_value
: _ CI.fatptr -> Unsigned.uint16
= "mmdb_stub_21_mmdb_ml_get_entry_data_uint16_value"
external mmdb_stub_22_mmdb_ml_get_entry_data_uint32_value
: _ CI.fatptr -> Unsigned.uint32
= "mmdb_stub_22_mmdb_ml_get_entry_data_uint32_value"
external mmdb_stub_23_mmdb_ml_get_entry_data_int32_value
: _ CI.fatptr -> int32 = "mmdb_stub_23_mmdb_ml_get_entry_data_int32_value"
external mmdb_stub_24_mmdb_ml_get_entry_data_uint64_value
: _ CI.fatptr -> Unsigned.uint64
= "mmdb_stub_24_mmdb_ml_get_entry_data_uint64_value"
external mmdb_stub_25_mmdb_ml_get_entry_data_boolean_value
: _ CI.fatptr -> bool = "mmdb_stub_25_mmdb_ml_get_entry_data_boolean_value"
external mmdb_stub_26_mmdb_ml_get_entry_data_float_value
: _ CI.fatptr -> float = "mmdb_stub_26_mmdb_ml_get_entry_data_float_value"
type 'a result = 'a
type 'a return = 'a
type 'a fn =
| Returns : 'a CI.typ -> 'a return fn
| Function : 'a CI.typ * 'b fn -> ('a -> 'b) fn
let map_result f x = f x
let returning t = Returns t
let (@->) f p = Function (f, p)
let foreign : type a b. string -> (a -> b) fn -> (a -> b) =
fun name t -> match t, name with
| Function (CI.Pointer _, Returns (CI.Primitive CI.Float)),
"mmdb_ml_get_entry_data_float_value" ->
(fun x1 ->
let CI.CPointer x2 = x1 in
mmdb_stub_26_mmdb_ml_get_entry_data_float_value x2)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Bool)),
"mmdb_ml_get_entry_data_boolean_value" ->
(fun x3 ->
let CI.CPointer x4 = x3 in
mmdb_stub_25_mmdb_ml_get_entry_data_boolean_value x4)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Uint64_t)),
"mmdb_ml_get_entry_data_uint64_value" ->
(fun x5 ->
let CI.CPointer x6 = x5 in
mmdb_stub_24_mmdb_ml_get_entry_data_uint64_value x6)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int32_t)),
"mmdb_ml_get_entry_data_int32_value" ->
(fun x7 ->
let CI.CPointer x8 = x7 in
mmdb_stub_23_mmdb_ml_get_entry_data_int32_value x8)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Uint32_t)),
"mmdb_ml_get_entry_data_uint32_value" ->
(fun x9 ->
let CI.CPointer x10 = x9 in
mmdb_stub_22_mmdb_ml_get_entry_data_uint32_value x10)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Uint16_t)),
"mmdb_ml_get_entry_data_uint16_value" ->
(fun x11 ->
let CI.CPointer x12 = x11 in
mmdb_stub_21_mmdb_ml_get_entry_data_uint16_value x12)
| Function (CI.Pointer _, Returns (CI.Pointer x15)),
"mmdb_ml_get_entry_data_bytes_value" ->
(fun x13 ->
let CI.CPointer x14 = x13 in
CI.make_ptr x15 (mmdb_stub_20_mmdb_ml_get_entry_data_bytes_value x14))
| Function (CI.Pointer _, Returns (CI.Primitive CI.Double)),
"mmdb_ml_get_entry_data_double_value" ->
(fun x16 ->
let CI.CPointer x17 = x16 in
mmdb_stub_19_mmdb_ml_get_entry_data_double_value x17)
| Function (CI.Pointer _, Returns (CI.Pointer x20)),
"mmdb_ml_get_entry_data_utf8_string_value" ->
(fun x18 ->
let CI.CPointer x19 = x18 in
CI.make_ptr x20
(mmdb_stub_18_mmdb_ml_get_entry_data_utf8_string_value x19))
| Function (CI.Pointer _, Returns (CI.Primitive CI.Uint32_t)),
"mmdb_ml_get_entry_data_size" ->
(fun x21 ->
let CI.CPointer x22 = x21 in mmdb_stub_17_mmdb_ml_get_entry_data_size x22)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Uint32_t)),
"mmdb_ml_get_entry_data_type" ->
(fun x23 ->
let CI.CPointer x24 = x23 in mmdb_stub_16_mmdb_ml_get_entry_data_type x24)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Bool)),
"mmdb_ml_get_entry_data_has_data" ->
(fun x25 ->
let CI.CPointer x26 = x25 in
mmdb_stub_15_mmdb_ml_get_entry_data_has_data x26)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Uint16_t)),
"mmdb_ml_binary_format_minor_version" ->
(fun x27 ->
let CI.CPointer x28 = x27 in
mmdb_stub_14_mmdb_ml_binary_format_minor_version x28)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Uint16_t)),
"mmdb_ml_binary_format_major_version" ->
(fun x29 ->
let CI.CPointer x30 = x29 in
mmdb_stub_13_mmdb_ml_binary_format_major_version x30)
| Function (CI.Pointer _, Returns (CI.Pointer x33)), "mmdb_ml_language_names" ->
(fun x31 ->
let CI.CPointer x32 = x31 in
CI.make_ptr x33 (mmdb_stub_12_mmdb_ml_language_names x32))
| Function (CI.Pointer _, Returns (CI.Primitive CI.Size_t)),
"mmdb_ml_language_count" ->
(fun x34 ->
let CI.CPointer x35 = x34 in mmdb_stub_11_mmdb_ml_language_count x35)
| Function (CI.Void, Returns (CI.Primitive CI.Size_t)),
"mmdb_ml_alignof_mmdb_entry_data_s" ->
mmdb_stub_10_mmdb_ml_alignof_mmdb_entry_data_s
| Function (CI.Void, Returns (CI.Primitive CI.Size_t)),
"mmdb_ml_sizeof_mmdb_entry_data_s" ->
mmdb_stub_9_mmdb_ml_sizeof_mmdb_entry_data_s
| Function (CI.Void, Returns (CI.Primitive CI.Size_t)),
"mmdb_ml_alignof_mmdb_s" -> mmdb_stub_8_mmdb_ml_alignof_mmdb_s
| Function (CI.Void, Returns (CI.Primitive CI.Size_t)),
"mmdb_ml_sizeof_mmdb_s" -> mmdb_stub_7_mmdb_ml_sizeof_mmdb_s
| Function (CI.Void, Returns (CI.Pointer x41)), "MMDB_lib_version" ->
(fun x40 -> CI.make_ptr x41 (mmdb_stub_6_MMDB_lib_version x40))
| Function (CI.Primitive CI.Int, Returns (CI.Pointer x43)), "MMDB_strerror" ->
(fun x42 -> CI.make_ptr x43 (mmdb_stub_5_MMDB_strerror x42))
| Function
(CI.Pointer _,
Function
(CI.Pointer _, Function (CI.Pointer _, Returns (CI.Primitive CI.Int)))),
"MMDB_aget_value" ->
(fun x44 x46 x48 ->
let CI.CPointer x49 = x48 in
let CI.CPointer x47 = x46 in
let CI.CPointer x45 = x44 in mmdb_stub_4_MMDB_aget_value x45 x47 x49)
| Function
(CI.Pointer _,
Function
(CI.Pointer _,
Function
(CI.Pointer _,
Function (CI.Pointer _, Returns (CI.Struct _ as x58))))),
"MMDB_lookup_string" ->
(fun x50 x52 x54 x56 ->
let CI.CPointer x57 = x56 in
let CI.CPointer x55 = x54 in
let CI.CPointer x53 = x52 in
let CI.CPointer x51 = x50 in
CI.make_structured x58 (mmdb_stub_3_MMDB_lookup_string x51 x53 x55 x57))
| Function (CI.Pointer _, Returns CI.Void), "MMDB_close" ->
(fun x59 -> let CI.CPointer x60 = x59 in mmdb_stub_2_MMDB_close x60)
| Function
(CI.Pointer _,
Function
(CI.Primitive CI.Int,
Function (CI.Pointer _, Returns (CI.Primitive CI.Int)))),
"MMDB_open" ->
(fun x61 x63 x64 ->
let CI.CPointer x65 = x64 in
let CI.CPointer x62 = x61 in mmdb_stub_1_MMDB_open x62 x63 x65)
| _, s -> Printf.ksprintf failwith "No match for %s" s
let foreign_value : type a. string -> a Ctypes.typ -> a Ctypes.ptr =
fun name t -> match t, name with
| _, s -> Printf.ksprintf failwith "No match for %s" s