|
| 1 | +// Part of the Crubit project, under the Apache License v2.0 with LLVM |
| 2 | +// Exceptions. See /LICENSE for license information. |
| 3 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | + |
| 5 | +// Automatically @generated C++ bindings for the following Rust crate: |
| 6 | +// example_crate_golden |
| 7 | +// Features: custom_ffi_types, non_unpin_ctor, std_unique_ptr, std_vector, |
| 8 | +// supported |
| 9 | + |
| 10 | +// clang-format off |
| 11 | +#ifndef THIRD_PARTY_CRUBIT_EXAMPLES_RUST_TRAIT_EXAMPLE_CRATE_GOLDEN |
| 12 | +#define THIRD_PARTY_CRUBIT_EXAMPLES_RUST_TRAIT_EXAMPLE_CRATE_GOLDEN |
| 13 | + |
| 14 | +#pragma clang diagnostic push |
| 15 | +#pragma clang diagnostic ignored "-Wreturn-type-c-linkage" |
| 16 | +#include "support/annotations_internal.h" |
| 17 | +#include "support/internal/slot.h" |
| 18 | +#include "support/rs_std/str_ref.h" |
| 19 | +#include "support/rs_std/traits.h" |
| 20 | + |
| 21 | +#include <cstddef> |
| 22 | +#include <cstdint> |
| 23 | +#include <type_traits> |
| 24 | +#include <utility> |
| 25 | + |
| 26 | +namespace example_crate { |
| 27 | + |
| 28 | +// Generated from: |
| 29 | +// examples/rust/trait/example.rs;l=12 |
| 30 | +struct CRUBIT_INTERNAL_RUST_TYPE(":: example_crate_golden :: MyStruct") alignas( |
| 31 | + 4) [[clang::trivial_abi]] MyStruct final { |
| 32 | + public: |
| 33 | + // Default::default |
| 34 | + MyStruct(); |
| 35 | + |
| 36 | + // No custom `Drop` impl and no custom "drop glue" required |
| 37 | + ~MyStruct() = default; |
| 38 | + MyStruct(MyStruct&&) = default; |
| 39 | + ::example_crate::MyStruct& operator=(MyStruct&&) = default; |
| 40 | + |
| 41 | + // Rust types that are `Copy` get trivial, `default` C++ copy constructor and |
| 42 | + // assignment operator. |
| 43 | + MyStruct(const MyStruct&) = default; |
| 44 | + ::example_crate::MyStruct& operator=(const MyStruct&) = default; |
| 45 | + MyStruct(::crubit::UnsafeRelocateTag, MyStruct&& value) { |
| 46 | + memcpy(this, &value, sizeof(value)); |
| 47 | + } |
| 48 | + |
| 49 | + // Generated from: |
| 50 | + // examples/rust/trait/example.rs;l=17 |
| 51 | + static ::example_crate::MyStruct new_(std::int32_t x); |
| 52 | + |
| 53 | + private: |
| 54 | + union { |
| 55 | + // Generated from: |
| 56 | + // examples/rust/trait/example.rs;l=13 |
| 57 | + std::int32_t x; |
| 58 | + }; |
| 59 | + |
| 60 | + private: |
| 61 | + static void __crubit_field_offset_assertions(); |
| 62 | +}; |
| 63 | + |
| 64 | +// Generated from: examples/rust/trait/example.rs;l=5 |
| 65 | +struct CRUBIT_INTERNAL_RUST_TYPE(":: example_crate_golden :: MyTrait") MyTrait { |
| 66 | + template <typename T> |
| 67 | + using impl = rs_std::impl<T, MyTrait>; |
| 68 | +}; |
| 69 | + |
| 70 | +static_assert( |
| 71 | + sizeof(MyStruct) == 4, |
| 72 | + "Verify that ADT layout didn't change since this header got generated"); |
| 73 | +static_assert( |
| 74 | + alignof(MyStruct) == 4, |
| 75 | + "Verify that ADT layout didn't change since this header got generated"); |
| 76 | +namespace __crubit_internal { |
| 77 | +extern "C" void __crubit_thunk_default(::example_crate::MyStruct* __ret_ptr); |
| 78 | +} |
| 79 | +inline ::example_crate::MyStruct::MyStruct() { |
| 80 | + __crubit_internal::__crubit_thunk_default(this); |
| 81 | +} |
| 82 | +static_assert(std::is_trivially_destructible_v<MyStruct>); |
| 83 | +static_assert( |
| 84 | + std::is_trivially_move_constructible_v<::example_crate::MyStruct>); |
| 85 | +static_assert(std::is_trivially_move_assignable_v<::example_crate::MyStruct>); |
| 86 | +static_assert( |
| 87 | + std::is_trivially_copy_constructible_v<::example_crate::MyStruct>); |
| 88 | +static_assert(std::is_trivially_copy_assignable_v<::example_crate::MyStruct>); |
| 89 | +namespace __crubit_internal { |
| 90 | +extern "C" void __crubit_thunk_new(std::int32_t, |
| 91 | + ::example_crate::MyStruct* __ret_ptr); |
| 92 | +} |
| 93 | +inline ::example_crate::MyStruct MyStruct::new_(std::int32_t x) { |
| 94 | + crubit::Slot<::example_crate::MyStruct> __return_value_ret_val_holder; |
| 95 | + auto* __return_value_storage = __return_value_ret_val_holder.Get(); |
| 96 | + __crubit_internal::__crubit_thunk_new(x, __return_value_storage); |
| 97 | + return std::move(__return_value_ret_val_holder).AssumeInitAndTakeValue(); |
| 98 | +} |
| 99 | +inline void MyStruct::__crubit_field_offset_assertions() { |
| 100 | + static_assert(0 == offsetof(MyStruct, x)); |
| 101 | +} |
| 102 | +} // namespace example_crate |
| 103 | + |
| 104 | +template <> |
| 105 | +struct rs_std::impl<::example_crate::MyStruct, ::example_crate::MyTrait> { |
| 106 | + static constexpr bool kIsImplemented = true; |
| 107 | + |
| 108 | + // Generated from: |
| 109 | + // examples/rust/trait/example.rs;l=23 |
| 110 | + static std::int32_t add_with(::example_crate::MyStruct const& self, |
| 111 | + std::int32_t y); |
| 112 | + |
| 113 | + // Generated from: |
| 114 | + // examples/rust/trait/example.rs;l=27 |
| 115 | + static rs_std::StrRef describe(::example_crate::MyStruct const& self); |
| 116 | +}; |
| 117 | + |
| 118 | +namespace example_crate { |
| 119 | +namespace __crubit_internal { |
| 120 | +extern "C" std::int32_t __crubit_thunk_MyTrait_uadd_uwith( |
| 121 | + ::example_crate::MyStruct const&, std::int32_t); |
| 122 | +} |
| 123 | +} // namespace example_crate |
| 124 | +inline std::int32_t |
| 125 | +rs_std::impl<::example_crate::MyStruct, ::example_crate::MyTrait>::add_with( |
| 126 | + ::example_crate::MyStruct const& self, std::int32_t y) { |
| 127 | + return example_crate::__crubit_internal::__crubit_thunk_MyTrait_uadd_uwith( |
| 128 | + self, y); |
| 129 | +} |
| 130 | + |
| 131 | +namespace example_crate { |
| 132 | +namespace __crubit_internal { |
| 133 | +extern "C" rs_std::StrRef __crubit_thunk_MyTrait_udescribe( |
| 134 | + ::example_crate::MyStruct const&); |
| 135 | +} |
| 136 | +} // namespace example_crate |
| 137 | +inline rs_std::StrRef |
| 138 | +rs_std::impl<::example_crate::MyStruct, ::example_crate::MyTrait>::describe( |
| 139 | + ::example_crate::MyStruct const& self) { |
| 140 | + return example_crate::__crubit_internal::__crubit_thunk_MyTrait_udescribe( |
| 141 | + self); |
| 142 | +} |
| 143 | + |
| 144 | +#pragma clang diagnostic pop |
| 145 | +#endif // THIRD_PARTY_CRUBIT_EXAMPLES_RUST_TRAIT_EXAMPLE_CRATE_GOLDEN |
0 commit comments