brick-lang/linenoise-ml — pull request #1 by yallop (2014-03-19 09:37:30+00:00)
Title: Update code to use latest ctypes stub generation interface.

The ctypes interface for stub generation has changed a bit. This patch updates the linenoise bindings to use the new interface.

The main change in the [new ctypes interface][new-cstubs] is that you now apply the `Bindings` functor twice. First, you [pass it to Cstubs][bindings-application-1], which uses it to generate the stub code. You then [apply it to the generated ML module][bindings-application-2], which links in the C stubs.

While this is conceptually slightly more complex, it actually simplifies the bindings code in practice; using the same functor for generation and linking means that there's no need to register views and struct types. This simplification shows up in the changes in this pull request, which are mostly in [linenoise_bindings.ml][linenoise-bindings-changes]: the calls to `register_paths` are now gone, and the calls to `write_c` and `write_ml` are simpler.

The new ctypes stub generation interface isn't yet documented, since it's not released, but there are some details in [the pull request that introduced the change][cstubs-pull-request].

[bindings-application-1]: https://github.com/yallop/linenoise-ml/blob/aff3b768c40aaf6a8cb9febbb1617cc4c76de87c/linenoise_bindings.ml#L61-L62
[bindings-application-2]: https://github.com/yallop/linenoise-ml/blob/aff3b768c40aaf6a8cb9febbb1617cc4c76de87c/linenoise.ml#L1
[linenoise-bindings-changes]: https://github.com/yallop/linenoise-ml/compare/923ca3c6b4...new-cstubs-interface#diff-f1022eeb7126f0c32b2a0154181c214c
[new-cstubs]: https://github.com/ocamllabs/ocaml-ctypes/blob/6e87ed4a30b41f2a994d3f16000d39991b98dfb7/src/cstubs/cstubs.mli
[cstubs-pull-request]: https://github.com/ocamllabs/ocaml-ctypes/pull/129