Wire_stubsSourceOCaml FFI stub generation for EverParse-produced C validators.
Wire_stubs generates C stubs and matching OCaml external declarations so OCaml code can call EverParse-generated validators. Each stub stack- allocates the schema's default plug struct (<Name>Fields from Wire_3d), runs the EverParse validator against it, then marshals the populated struct members into an OCaml record. On validation failure, Failure is raised.
Typical usage (in a code-generation executable):
let () =
Wire_stubs.generate ~schema_dir:"schemas" ~outdir:"." [ C my_codec ]This writes wire_ffi.c + stubs.ml into outdir. The WIRECTX socket and the <Name>_Fields plug come from Wire_3d; this module is just one particular consumer of that plug.
generate ~schema_dir ~outdir codecs writes all FFI artifacts.
val of_structs :
schema_dir:string ->
outdir:string ->
Wire.Everparse.Raw.struct_ list ->
unitSame as generate but takes raw structs directly.
These are the building blocks used by generate. Most users should not need them directly.
Generate OCaml external declarations and record types for all structs.
Generate a standalone OCaml module with parse and parse_k for one struct.
Derive the OCaml snake_case module name from a struct's CamelCase name.
Convert a Wire struct name to the EverParse CamelCase convention.