witx_codegen/cpp/
header.rs

1use super::*;
2use std::io::Write;
3
4impl CppGenerator {
5    pub fn header<T: Write>(w: &mut PrettyWriter<T>) -> Result<(), Error> {
6        w.write_lines(
7            "
8/*
9 * This file was automatically generated by witx-codegen - Do not edit manually.
10 */
11#include <cstdint>
12#include <cstring>
13#include <tuple>
14#include <cstddef>
15#include <variant>
16
17// namespace WitxCodegenHeader {
18using WasiHandle = int32_t;
19template <typename T> using WasiPtr = T *const;
20template <typename T> using WasiMutPtr = T *;
21using WasiStringBytesPtr = WasiPtr<unsigned char>;
22
23template <typename R, typename E> using Expected = std::variant<R, E>;
24
25using WasiStringBytesPtr = WasiPtr<unsigned char>;
26struct WasiString {
27    WasiStringBytesPtr ptr;
28    size_t length;
29};
30
31template<typename T>
32struct WasiSlice {
33    WasiPtr<T> ptr;
34    size_t length;
35};
36
37template<typename T>
38struct WasiMutSlice {
39    WasiMutPtr<T> ptr;
40    size_t length;
41};
42
43// }
44",
45        )?
46        .eob()?;
47        Ok(())
48    }
49}