(doc: &Document, inputs_str: &str)
| 5 | use witx::*; |
| 6 | |
| 7 | pub fn to_cpp_header(doc: &Document, inputs_str: &str) -> String { |
| 8 | let mut ret = String::new(); |
| 9 | |
| 10 | ret.push_str(&format!( |
| 11 | r#"// SPDX-License-Identifier: Apache-2.0 |
| 12 | // SPDX-FileCopyrightText: 2019-2024 Second State INC |
| 13 | |
| 14 | /** |
| 15 | * THIS FILE IS AUTO-GENERATED from the following files: |
| 16 | * {} |
| 17 | * |
| 18 | * @file |
| 19 | * This file describes the [WASI] interface, consisting of functions, types, |
| 20 | * and defined values (macros). |
| 21 | * |
| 22 | * The interface described here is greatly inspired by [CloudABI]'s clean, |
| 23 | * thoughtfully-designed, capability-oriented, POSIX-style API. |
| 24 | * |
| 25 | * [CloudABI]: https://github.com/NuxiNL/cloudlibc |
| 26 | * [WASI]: https://github.com/WebAssembly/WASI/ |
| 27 | */ |
| 28 | |
| 29 | #pragma once |
| 30 | |
| 31 | #include <cstddef> |
| 32 | #include <cstdint> |
| 33 | #include <type_traits> |
| 34 | |
| 35 | using const_uint8_t_ptr = uint32_t; |
| 36 | using uint8_t_ptr = uint32_t; |
| 37 | |
| 38 | #define DEFINE_ENUM_OPERATORS(type) \ |
| 39 | inline constexpr type operator~(type a) noexcept {{ \ |
| 40 | return static_cast<type>(~static_cast<std::underlying_type_t<type>>(a)); \ |
| 41 | }} \ |
| 42 | inline constexpr type operator|(type a, type b) noexcept {{ \ |
| 43 | return static_cast<type>(static_cast<std::underlying_type_t<type>>(a) | \ |
| 44 | static_cast<std::underlying_type_t<type>>(b)); \ |
| 45 | }} \ |
| 46 | inline constexpr type &operator|=(type &a, type b) noexcept {{ \ |
| 47 | a = a | b; \ |
| 48 | return a; \ |
| 49 | }} \ |
| 50 | inline constexpr type operator&(type a, type b) noexcept {{ \ |
| 51 | return static_cast<type>(static_cast<std::underlying_type_t<type>>(a) & \ |
| 52 | static_cast<std::underlying_type_t<type>>(b)); \ |
| 53 | }} \ |
| 54 | inline constexpr type &operator&=(type &a, type b) noexcept {{ \ |
| 55 | a = a & b; \ |
| 56 | return a; \ |
| 57 | }} |
| 58 | |
| 59 | static_assert(alignof(int8_t) == 1, "non-wasi data layout"); |
| 60 | static_assert(alignof(uint8_t) == 1, "non-wasi data layout"); |
| 61 | static_assert(alignof(int16_t) == 2, "non-wasi data layout"); |
| 62 | static_assert(alignof(uint16_t) == 2, "non-wasi data layout"); |
| 63 | static_assert(alignof(int32_t) == 4, "non-wasi data layout"); |
| 64 | static_assert(alignof(uint32_t) == 4, "non-wasi data layout"); |
no test coverage detected