fdopen / ctypes-zarith

Demo how to mix ctypes and "custom" OCaml types
Other
4 stars 5 forks source link

Made visible 3 lower-level functions for each of MPZ and MPQ #2

Closed disteph closed 4 years ago

disteph commented 4 years ago

By experimenting with the bindings I realised I need the 3 lower-level functions (clear, init_set, and the handler). That's because in C functions manipulating GMP integers, you can find arrays of mpz integers, and these are not arrays of pointers but 2-dimensional arrays (because mpz_t is not a pointer but a 1-cell array). Hence, in order to feed the following C function (from my use case)

yices_poly_mpz(uint32_t n, const mpz_t z[], const term_t t[])

the current interface of ctypes-zarith was not sufficient: we need to allocate a contiguous array of mpz (and calling MPZ.make() one integer at a time doesn't make them contiguous). Hence the use to access the handler for MPZ.t abstract, clear, and init_set for doing an n-ary allocation and filling the cells.

disteph commented 4 years ago

Here's just a ping on this PR: our usage of ctypes-zarith in our project has not changed since commit 67f6ab0 a month ago; it works well and I consider it stable. There shouldn't be any more PR or commit on this. As we would like to release version 1.0 of our project on opam, is there a chance you would merge this PR and push it to opam as well, so that we can have ctypes-zarith as an opam dependency?

fdopen commented 4 years ago

Sorry, I don't have the time to review it. I will just merge it and release it.

disteph commented 4 years ago

Thanks!