ocaml-ctypes icon indicating copy to clipboard operation
ocaml-ctypes copied to clipboard

Merge Cstubs and Cstubs_inverted

Open whitequark opened this issue 10 years ago • 4 comments

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.

whitequark avatar Feb 27 '15 08:02 whitequark

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)

whitequark avatar Feb 27 '15 09:02 whitequark

@yallop Any opinion on this?

whitequark avatar Mar 25 '16 13:03 whitequark

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.

yallop avatar Mar 30 '16 13:03 yallop

Oh, I actually used unit there, it was an editing error.

whitequark avatar Mar 30 '16 13:03 whitequark