| // Part of the Crubit project, under the Apache License v2.0 with LLVM |
| // Exceptions. See /LICENSE for license information. |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| |
| // Automatically @generated C++ bindings for the following Rust crate: |
| // example_crate_golden |
| |
| // clang-format off |
| #ifndef THIRD_PARTY_CRUBIT_EXAMPLES_RUST_ENUM_EXAMPLE_CRATE_GOLDEN |
| #define THIRD_PARTY_CRUBIT_EXAMPLES_RUST_ENUM_EXAMPLE_CRATE_GOLDEN |
| |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wreturn-type-c-linkage" |
| #pragma clang diagnostic ignored "-Wunused-private-field" |
| #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
| #pragma clang diagnostic ignored "-Wignored-attributes" |
| #include "support/annotations_internal.h" |
| #include "support/internal/slot.h" |
| |
| #include <array> |
| #include <cstddef> |
| #include <cstring> |
| #include <type_traits> |
| |
| namespace example_crate { |
| |
| struct CRUBIT_INTERNAL_RUST_TYPE(":: example_crate_golden :: Color") alignas(1) |
| [[clang::trivial_abi]] Color final { |
| public: |
| // Default::default |
| Color(); |
| |
| static constexpr Color MakeRed(); |
| |
| static constexpr Color MakeBlue(); |
| |
| static constexpr Color MakeGreen(); |
| |
| // No custom `Drop` impl and no custom "drop glue" required |
| ~Color() = default; |
| Color(Color&&) = default; |
| Color& operator=(Color&&) = default; |
| |
| // Rust types that are `Copy` get trivial, `default` C++ copy constructor and |
| // assignment operator. |
| Color(const Color&) = default; |
| Color& operator=(const Color&) = default; |
| Color(::crubit::UnsafeRelocateTag, Color&& value); |
| |
| private: |
| // Field type has been replaced with a blob of bytes: No support for bindings |
| // of individual non-repr(C) `enum`s |
| ::std::array<unsigned char, 1> __opaque_blob_of_bytes; |
| |
| private: |
| struct PrivateBytesTag {}; |
| constexpr Color(PrivateBytesTag, ::std::array<unsigned char, 1> bytes) |
| : __opaque_blob_of_bytes(bytes) {} |
| |
| private: |
| static void __crubit_field_offset_assertions(); |
| }; |
| |
| static_assert( |
| sizeof(::example_crate::Color) == 1, |
| "Verify that ADT layout didn't change since this header got generated"); |
| static_assert( |
| alignof(::example_crate::Color) == 1, |
| "Verify that ADT layout didn't change since this header got generated"); |
| namespace __crubit_internal { |
| extern "C" void |
| __crubit_thunk_Default_udefault_uexample_ucrate_ugolden_x0000003a_x0000003aColor( |
| ::example_crate::Color* __ret_ptr); |
| } |
| inline ::example_crate::Color::Color() { |
| __crubit_internal:: |
| __crubit_thunk_Default_udefault_uexample_ucrate_ugolden_x0000003a_x0000003aColor( |
| this); |
| } |
| // `static` constructor |
| inline constexpr ::example_crate::Color(::example_crate::Color::MakeRed)() { |
| return Color(PrivateBytesTag{}, {0}); |
| } |
| |
| // `static` constructor |
| inline constexpr ::example_crate::Color(::example_crate::Color::MakeBlue)() { |
| return Color(PrivateBytesTag{}, {1}); |
| } |
| |
| // `static` constructor |
| inline constexpr ::example_crate::Color(::example_crate::Color::MakeGreen)() { |
| return Color(PrivateBytesTag{}, {2}); |
| } |
| static_assert(::std::is_trivially_destructible_v<::example_crate::Color>); |
| static_assert(::std::is_trivially_move_constructible_v<::example_crate::Color>); |
| static_assert(::std::is_trivially_move_assignable_v<::example_crate::Color>); |
| static_assert(::std::is_trivially_copy_constructible_v<::example_crate::Color>); |
| static_assert(::std::is_trivially_copy_assignable_v<::example_crate::Color>); |
| inline ::example_crate::Color::Color(::crubit::UnsafeRelocateTag, |
| Color&& value) { |
| ::std::memcpy(this, &value, sizeof(value)); |
| } |
| inline void ::example_crate::Color::__crubit_field_offset_assertions() { |
| { |
| using __crubit_assert_type = ::example_crate::Color; |
| static_assert(0 == offsetof(__crubit_assert_type, __opaque_blob_of_bytes)); |
| } |
| } |
| } // namespace example_crate |
| |
| #pragma clang diagnostic pop |
| #endif // THIRD_PARTY_CRUBIT_EXAMPLES_RUST_ENUM_EXAMPLE_CRATE_GOLDEN |