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