package wire
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=dfd1fd578e84bd652ddb0064b3ee87d47780cc62e24180f3e5a92413bafad87a
sha512=125ada27127533b6130885d7b62f31c7ad4fc355a236258326b85c12792031c95d84fe68751264402f2efa7e09d70dd8bb5d06660e9a416e71a9a140f9658ed1
doc/wire.stubs/Wire_stubs/index.html
Module Wire_stubsSource
OCaml 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.
Individual generators
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.