Overview of gen_js_api
mastergen_js_api is a tool designed to simplify the creation of OCaml bindings for JavaScript libraries. It is primarily intended for use with the js_of_ocaml compiler, though it is designed with the possibility of supporting other runtimes (like Bucklescript or embedded JS engines) in the future.
Core Principles
- Signature-driven generation: Authors write OCaml signatures (
.mli) for JavaScript libraries, and the tool generates the implementation code using implicit conventions and explicit annotations. - Automatic translation: The generated code handles the translation of values between OCaml and JavaScript and manages JavaScript calling conventions.
- Standard OCaml client code: All syntactic processing is handled during the binding generation phase. This ensures that the final client code is standard OCaml and does not require custom syntax or JS-specific types.