Open mwlon opened 5 months ago
This would still require to have foo
s around which, somehow, return custom_block
value
s, hence, some kind of OCaml-specific C stubs.
What if custom_block_t
could (somehow) take the address of a custom_operations
as an argument, so any regular C function taking or returning some value (to be extracted from/embedded in a custom_block
in the generated stubs) could be used? (Note I didn't give this much thought, it may not be possible at all of course).
@NicolasT I think that approach might not work, since we also need to inform OCaml of size
, used
, and sometimes max
, which might be dynamically determined upon each allocation. Custom blocks are definitely a power-user feature, so it seems reasonable and easier to me if we leave their usage to the user.
Right. For the use-case I had in mind, the wrapped value is always a pointer itself, so size is a known constant. used
and max
could be 0 and 1 since I can't know how the actual size of whatever is behind that pointer anyway :)
For that use case, could you just use a ptr void
type? I think ctypes handles that out-of-the-box
As far as I can tell, there is no way in ctypes to return a custom block. I'd imagine this would work something like the following:
binding:
generated C stub:
Is this already implemented and just something I overlooked? If not, this seems like an important piece of functionality to add.