ocaml-ctypes
ocaml-ctypes copied to clipboard
Merge Cstubs and Cstubs_inverted
When they're separate, it becomes very annoying (actually, I've not yet figured out whether it is possible at all) to call some Cstubs-imported functions from Cstubs_inverted-exported functions.
I did this and it seems to work:
module No_foreign : Cstubs.FOREIGN = struct
type 'a fn = unit
let foreign name typ = ()
let foreign_value name typ = ()
end
module No_internal : Cstubs_inverted.INTERNAL = struct
let enum values typ = ()
let structure typ = ()
let union typ = ()
let typedef typ name = ()
let internal ?runtime_lock name fn impl = ()
end
module Bindings_export(I: Cstubs_inverted.INTERNAL) = X_bindings.C(Core)(No_foreign)(I)
module Bindings_import(F: Cstubs.FOREIGN) = X_bindings.C(Core)(F)(No_internal)
@yallop Any opinion on this?
I think that your definition of No_foreign is quite interesting: probably not what you intended to write, but indistinguishable from the "correct" solution (with type 'a fn = unit).
That aside, your solution looks entirely reasonable.
Oh, I actually used unit there, it was an editing error.