Oct. 10th, Thursday - 15:00 - 15:30
Generating ergonomic C++ APIs using Rustdoc, procedural macros, and Serde
This talk introduces a novel approach to generate C++ APIs from an existing Rust API by using procedural macros, Rustdoc, and Serde. Functions and impl blocks which should be exposed in the C++ API are annotated with a procedural macro attribute. This macro generates low level extern “C” functions for the corresponding function definitions. Arguments and return values of these functions are passed as byte buffers in this case. Ultimately, Rustdoc’s unstable JSON format is used to generate a set of low level bindings for the generated extern “C” functions and, on top of that, a set of ergonomic high level C++ bindings. An intermediate layer handles all the required (de-)serializing of the argument/return type byte buffers to acquire the corresponding native representations.