| 1 | #include "base/rust.h" |
| 2 | #include "engine/shared/uuid_manager.h" |
| 3 | #include <cstddef> |
| 4 | #include <cstdint> |
| 5 | #include <memory> |
| 6 | #include <new> |
| 7 | #include <type_traits> |
| 8 | #include <utility> |
| 9 | |
| 10 | namespace rust { |
| 11 | inline namespace cxxbridge1 { |
| 12 | // #include "rust/cxx.h" |
| 13 | |
| 14 | #ifndef CXXBRIDGE1_IS_COMPLETE |
| 15 | #define CXXBRIDGE1_IS_COMPLETE |
| 16 | namespace detail { |
| 17 | namespace { |
| 18 | template <typename T, typename = std::size_t> |
| 19 | struct is_complete : std::false_type {}; |
| 20 | template <typename T> |
| 21 | struct is_complete<T, decltype(sizeof(T))> : std::true_type {}; |
| 22 | } // namespace |
| 23 | } // namespace detail |
| 24 | #endif // CXXBRIDGE1_IS_COMPLETE |
| 25 | |
| 26 | #ifndef CXXBRIDGE1_RELOCATABLE |
| 27 | #define CXXBRIDGE1_RELOCATABLE |
| 28 | namespace detail { |
| 29 | template <typename... Ts> |
| 30 | struct make_void { |
| 31 | using type = void; |
| 32 | }; |
| 33 | |
| 34 | template <typename... Ts> |
| 35 | using void_t = typename make_void<Ts...>::type; |
| 36 | |
| 37 | template <typename Void, template <typename...> class, typename...> |
| 38 | struct detect : std::false_type {}; |
| 39 | template <template <typename...> class T, typename... A> |
| 40 | struct detect<void_t<T<A...>>, T, A...> : std::true_type {}; |
| 41 | |
| 42 | template <template <typename...> class T, typename... A> |
| 43 | using is_detected = detect<void, T, A...>; |
| 44 | |
| 45 | template <typename T> |
| 46 | using detect_IsRelocatable = typename T::IsRelocatable; |
| 47 | |
| 48 | template <typename T> |
| 49 | struct get_IsRelocatable |
| 50 | : std::is_same<typename T::IsRelocatable, std::true_type> {}; |
| 51 | } // namespace detail |
| 52 | |
| 53 | template <typename T> |
| 54 | struct IsRelocatable |
| 55 | : std::conditional< |
| 56 | detail::is_detected<detail::detect_IsRelocatable, T>::value, |
| 57 | detail::get_IsRelocatable<T>, |
| 58 | std::integral_constant< |
| 59 | bool, std::is_trivially_move_constructible<T>::value && |
| 60 | std::is_trivially_destructible<T>::value>>::type {}; |
| 61 | #endif // CXXBRIDGE1_RELOCATABLE |
| 62 | |
| 63 | namespace { |
| 64 | template <bool> struct deleter_if { |
| 65 | template <typename T> void operator()(T *) {} |
| 66 | }; |
| 67 | |
| 68 | template <> struct deleter_if<true> { |
| 69 | template <typename T> void operator()(T *ptr) { ptr->~T(); } |
| 70 | }; |
| 71 | } // namespace |
| 72 | } // namespace cxxbridge1 |
| 73 | } // namespace rust |
| 74 | |
| 75 | using CUuidManager = ::CUuidManager; |
| 76 | |
| 77 | static_assert( |
| 78 | ::rust::IsRelocatable<::StrRef>::value, |
| 79 | "type StrRef should be trivially move constructible and trivially destructible in C++ to be used as an argument of `CalculateUuid`, `RegisterName` or return value of `GetName` in Rust" ); |
| 80 | static_assert( |
| 81 | ::rust::IsRelocatable<::CUuid>::value, |
| 82 | "type CUuid should be trivially move constructible and trivially destructible in C++ to be used as an argument of `LookupUuid` or return value of `RandomUuid`, `CalculateUuid`, `GetUuid` in Rust" ); |
| 83 | |
| 84 | extern "C" { |
| 85 | void cxxbridge1$RandomUuid(::CUuid *return$) noexcept { |
| 86 | ::CUuid (*RandomUuid$)() = ::RandomUuid; |
| 87 | new (return$) ::CUuid(RandomUuid$()); |
| 88 | } |
| 89 | |
| 90 | void cxxbridge1$CalculateUuid(::StrRef *name, ::CUuid *return$) noexcept { |
| 91 | ::CUuid (*CalculateUuid$)(::StrRef) = ::CalculateUuid; |
| 92 | new (return$) ::CUuid(CalculateUuid$(::std::move(*name))); |
| 93 | } |
| 94 | |
| 95 | void cxxbridge1$CUuidManager$RegisterName(::CUuidManager &self, ::std::int32_t id, ::StrRef *name) noexcept { |
| 96 | void (::CUuidManager::*RegisterName$)(::std::int32_t, ::StrRef) = &::CUuidManager::RegisterName; |
| 97 | (self.*RegisterName$)(id, ::std::move(*name)); |
| 98 | } |
| 99 | |
| 100 | void cxxbridge1$CUuidManager$GetUuid(const ::CUuidManager &self, ::std::int32_t id, ::CUuid *return$) noexcept { |
| 101 | ::CUuid (::CUuidManager::*GetUuid$)(::std::int32_t) const = &::CUuidManager::GetUuid; |
| 102 | new (return$) ::CUuid((self.*GetUuid$)(id)); |
| 103 | } |
| 104 | |
| 105 | void cxxbridge1$CUuidManager$GetName(const ::CUuidManager &self, ::std::int32_t id, ::StrRef *return$) noexcept { |
| 106 | ::StrRef (::CUuidManager::*GetName$)(::std::int32_t) const = &::CUuidManager::GetName; |
| 107 | new (return$) ::StrRef((self.*GetName$)(id)); |
| 108 | } |
| 109 | |
| 110 | ::std::int32_t cxxbridge1$CUuidManager$LookupUuid(const ::CUuidManager &self, ::CUuid *uuid) noexcept { |
| 111 | ::std::int32_t (::CUuidManager::*LookupUuid$)(::CUuid) const = &::CUuidManager::LookupUuid; |
| 112 | return (self.*LookupUuid$)(::std::move(*uuid)); |
| 113 | } |
| 114 | |
| 115 | ::std::int32_t cxxbridge1$CUuidManager$NumUuids(const ::CUuidManager &self) noexcept { |
| 116 | ::std::int32_t (::CUuidManager::*NumUuids$)() const = &::CUuidManager::NumUuids; |
| 117 | return (self.*NumUuids$)(); |
| 118 | } |
| 119 | |
| 120 | void cxxbridge1$CUuidManager$DebugDump(const ::CUuidManager &self) noexcept { |
| 121 | void (::CUuidManager::*DebugDump$)() const = &::CUuidManager::DebugDump; |
| 122 | (self.*DebugDump$)(); |
| 123 | } |
| 124 | |
| 125 | ::CUuidManager *cxxbridge1$CUuidManager_New() noexcept { |
| 126 | ::std::unique_ptr<::CUuidManager> (*CUuidManager_New$)() = ::CUuidManager_New; |
| 127 | return CUuidManager_New$().release(); |
| 128 | } |
| 129 | |
| 130 | const ::CUuidManager *cxxbridge1$CUuidManager_Global() noexcept { |
| 131 | const ::CUuidManager &(*CUuidManager_Global$)() = ::CUuidManager_Global; |
| 132 | return &CUuidManager_Global$(); |
| 133 | } |
| 134 | |
| 135 | static_assert(::rust::detail::is_complete<::CUuidManager>::value, "definition of CUuidManager is required" ); |
| 136 | static_assert(sizeof(::std::unique_ptr<::CUuidManager>) == sizeof(void *), "" ); |
| 137 | static_assert(alignof(::std::unique_ptr<::CUuidManager>) == alignof(void *), "" ); |
| 138 | void cxxbridge1$unique_ptr$CUuidManager$null(::std::unique_ptr<::CUuidManager> *ptr) noexcept { |
| 139 | ::new (ptr) ::std::unique_ptr<::CUuidManager>(); |
| 140 | } |
| 141 | void cxxbridge1$unique_ptr$CUuidManager$raw(::std::unique_ptr<::CUuidManager> *ptr, ::CUuidManager *raw) noexcept { |
| 142 | ::new (ptr) ::std::unique_ptr<::CUuidManager>(raw); |
| 143 | } |
| 144 | const ::CUuidManager *cxxbridge1$unique_ptr$CUuidManager$get(const ::std::unique_ptr<::CUuidManager>& ptr) noexcept { |
| 145 | return ptr.get(); |
| 146 | } |
| 147 | ::CUuidManager *cxxbridge1$unique_ptr$CUuidManager$release(::std::unique_ptr<::CUuidManager>& ptr) noexcept { |
| 148 | return ptr.release(); |
| 149 | } |
| 150 | void cxxbridge1$unique_ptr$CUuidManager$drop(::std::unique_ptr<::CUuidManager> *ptr) noexcept { |
| 151 | ::rust::deleter_if<::rust::detail::is_complete<::CUuidManager>::value>{}(ptr); |
| 152 | } |
| 153 | } // extern "C" |
| 154 | |