witx-codegen 0.11.4

WITX code generator for WebAssembly guest modules.
Documentation
use super::*;
use std::io::Write;

impl CppGenerator {
    pub fn header<T: Write>(w: &mut PrettyWriter<T>) -> Result<(), Error> {
        w.write_lines(
            "
/*
 * This file was automatically generated by witx-codegen - Do not edit manually.
 */
#include <cstdint>
#include <cstring>
#include <tuple>
#include <cstddef>
#include <variant>

// namespace WitxCodegenHeader {
using WasiHandle = int32_t;
template <typename T> using WasiPtr = T *const;
template <typename T> using WasiMutPtr = T *;
using WasiStringBytesPtr = WasiPtr<unsigned char>;

template <typename R, typename E> using Expected = std::variant<R, E>;

using WasiStringBytesPtr = WasiPtr<unsigned char>;
struct WasiString {
    WasiStringBytesPtr ptr;
    size_t length;
};

template<typename T>
struct WasiSlice {
    WasiPtr<T> ptr;
    size_t length;
};

template<typename T>
struct WasiMutSlice {
    WasiMutPtr<T> ptr;
    size_t length;
};

// }
",
        )?
        .eob()?;
        Ok(())
    }
}