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
10namespace rust {
11inline namespace cxxbridge1 {
12// #include "rust/cxx.h"
13
14#ifndef CXXBRIDGE1_IS_COMPLETE
15#define CXXBRIDGE1_IS_COMPLETE
16namespace detail {
17namespace {
18template <typename T, typename = std::size_t>
19struct is_complete : std::false_type {};
20template <typename T>
21struct 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
28namespace detail {
29template <typename... Ts>
30struct make_void {
31 using type = void;
32};
33
34template <typename... Ts>
35using void_t = typename make_void<Ts...>::type;
36
37template <typename Void, template <typename...> class, typename...>
38struct detect : std::false_type {};
39template <template <typename...> class T, typename... A>
40struct detect<void_t<T<A...>>, T, A...> : std::true_type {};
41
42template <template <typename...> class T, typename... A>
43using is_detected = detect<void, T, A...>;
44
45template <typename T>
46using detect_IsRelocatable = typename T::IsRelocatable;
47
48template <typename T>
49struct get_IsRelocatable
50 : std::is_same<typename T::IsRelocatable, std::true_type> {};
51} // namespace detail
52
53template <typename T>
54struct 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
63namespace {
64template <bool> struct deleter_if {
65 template <typename T> void operator()(T *) {}
66};
67
68template <> struct deleter_if<true> {
69 template <typename T> void operator()(T *ptr) { ptr->~T(); }
70};
71} // namespace
72} // namespace cxxbridge1
73} // namespace rust
74
75using CUuidManager = ::CUuidManager;
76
77static_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");
80static_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
84extern "C" {
85void cxxbridge1$RandomUuid(::CUuid *return$) noexcept {
86 ::CUuid (*RandomUuid$)() = ::RandomUuid;
87 new (return$) ::CUuid(RandomUuid$());
88}
89
90void cxxbridge1$CalculateUuid(::StrRef *name, ::CUuid *return$) noexcept {
91 ::CUuid (*CalculateUuid$)(::StrRef) = ::CalculateUuid;
92 new (return$) ::CUuid(CalculateUuid$(::std::move(*name)));
93}
94
95void 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
100void 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
105void 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
120void 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
130const ::CUuidManager *cxxbridge1$CUuidManager_Global() noexcept {
131 const ::CUuidManager &(*CUuidManager_Global$)() = ::CUuidManager_Global;
132 return &CUuidManager_Global$();
133}
134
135static_assert(::rust::detail::is_complete<::CUuidManager>::value, "definition of CUuidManager is required");
136static_assert(sizeof(::std::unique_ptr<::CUuidManager>) == sizeof(void *), "");
137static_assert(alignof(::std::unique_ptr<::CUuidManager>) == alignof(void *), "");
138void cxxbridge1$unique_ptr$CUuidManager$null(::std::unique_ptr<::CUuidManager> *ptr) noexcept {
139 ::new (ptr) ::std::unique_ptr<::CUuidManager>();
140}
141void cxxbridge1$unique_ptr$CUuidManager$raw(::std::unique_ptr<::CUuidManager> *ptr, ::CUuidManager *raw) noexcept {
142 ::new (ptr) ::std::unique_ptr<::CUuidManager>(raw);
143}
144const ::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}
150void 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