#include #include #include #include #include #include #include namespace rust { inline namespace cxxbridge1 { // #include "rust/cxx.h" namespace { template class impl; } // namespace class String; #ifndef CXXBRIDGE1_RUST_STR #define CXXBRIDGE1_RUST_STR class Str final { public: Str() noexcept; Str(const String &) noexcept; Str(const std::string &); Str(const char *); Str(const char *, std::size_t); Str &operator=(const Str &) &noexcept = default; explicit operator std::string() const; const char *data() const noexcept; std::size_t size() const noexcept; std::size_t length() const noexcept; bool empty() const noexcept; Str(const Str &) noexcept = default; ~Str() noexcept = default; using iterator = const char *; using const_iterator = const char *; const_iterator begin() const noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; bool operator==(const Str &) const noexcept; bool operator!=(const Str &) const noexcept; bool operator<(const Str &) const noexcept; bool operator<=(const Str &) const noexcept; bool operator>(const Str &) const noexcept; bool operator>=(const Str &) const noexcept; void swap(Str &) noexcept; private: class uninit; Str(uninit) noexcept; friend impl; std::array repr; }; #endif // CXXBRIDGE1_RUST_STR #ifndef CXXBRIDGE1_RUST_BOX #define CXXBRIDGE1_RUST_BOX template class Box final { public: using element_type = T; using const_pointer = typename std::add_pointer::type>::type; using pointer = typename std::add_pointer::type; Box() = delete; Box(Box &&) noexcept; ~Box() noexcept; explicit Box(const T &); explicit Box(T &&); Box &operator=(Box &&) &noexcept; const T *operator->() const noexcept; const T &operator*() const noexcept; T *operator->() noexcept; T &operator*() noexcept; template static Box in_place(Fields &&...); void swap(Box &) noexcept; static Box from_raw(T *) noexcept; T *into_raw() noexcept; /* Deprecated */ using value_type = element_type; private: class uninit; class allocation; Box(uninit) noexcept; void drop() noexcept; friend void swap(Box &lhs, Box &rhs) noexcept { lhs.swap(rhs); } T *ptr; }; template class Box::uninit {}; template class Box::allocation { static T *alloc() noexcept; static void dealloc(T *) noexcept; public: allocation() noexcept : ptr(alloc()) {} ~allocation() noexcept { if (this->ptr) { dealloc(this->ptr); } } T *ptr; }; template Box::Box(Box &&other) noexcept : ptr(other.ptr) { other.ptr = nullptr; } template Box::Box(const T &val) { allocation alloc; ::new (alloc.ptr) T(val); this->ptr = alloc.ptr; alloc.ptr = nullptr; } template Box::Box(T &&val) { allocation alloc; ::new (alloc.ptr) T(std::move(val)); this->ptr = alloc.ptr; alloc.ptr = nullptr; } template Box::~Box() noexcept { if (this->ptr) { this->drop(); } } template Box &Box::operator=(Box &&other) &noexcept { if (this->ptr) { this->drop(); } this->ptr = other.ptr; other.ptr = nullptr; return *this; } template const T *Box::operator->() const noexcept { return this->ptr; } template const T &Box::operator*() const noexcept { return *this->ptr; } template T *Box::operator->() noexcept { return this->ptr; } template T &Box::operator*() noexcept { return *this->ptr; } template template Box Box::in_place(Fields &&...fields) { allocation alloc; auto ptr = alloc.ptr; ::new (ptr) T{std::forward(fields)...}; alloc.ptr = nullptr; return from_raw(ptr); } template void Box::swap(Box &rhs) noexcept { using std::swap; swap(this->ptr, rhs.ptr); } template Box Box::from_raw(T *raw) noexcept { Box box = uninit{}; box.ptr = raw; return box; } template T *Box::into_raw() noexcept { T *raw = this->ptr; this->ptr = nullptr; return raw; } template Box::Box(uninit) noexcept {} #endif // CXXBRIDGE1_RUST_BOX #ifndef CXXBRIDGE1_RUST_OPAQUE #define CXXBRIDGE1_RUST_OPAQUE class Opaque { public: Opaque() = delete; Opaque(const Opaque &) = delete; ~Opaque() = delete; }; #endif // CXXBRIDGE1_RUST_OPAQUE #ifndef CXXBRIDGE1_IS_COMPLETE #define CXXBRIDGE1_IS_COMPLETE namespace detail { namespace { template struct is_complete : std::false_type {}; template struct is_complete : std::true_type {}; } // namespace } // namespace detail #endif // CXXBRIDGE1_IS_COMPLETE #ifndef CXXBRIDGE1_LAYOUT #define CXXBRIDGE1_LAYOUT class layout { template friend std::size_t size_of(); template friend std::size_t align_of(); template static typename std::enable_if::value, std::size_t>::type do_size_of() { return T::layout::size(); } template static typename std::enable_if::value, std::size_t>::type do_size_of() { return sizeof(T); } template static typename std::enable_if::value, std::size_t>::type size_of() { return do_size_of(); } template static typename std::enable_if::value, std::size_t>::type do_align_of() { return T::layout::align(); } template static typename std::enable_if::value, std::size_t>::type do_align_of() { return alignof(T); } template static typename std::enable_if::value, std::size_t>::type align_of() { return do_align_of(); } }; template std::size_t size_of() { return layout::size_of(); } template std::size_t align_of() { return layout::align_of(); } #endif // CXXBRIDGE1_LAYOUT } // namespace cxxbridge1 } // namespace rust struct SimpleDDR4; #ifndef CXXBRIDGE1_STRUCT_SimpleDDR4 #define CXXBRIDGE1_STRUCT_SimpleDDR4 struct SimpleDDR4 final : public ::rust::Opaque { void tick_ddr4() noexcept; bool try_send_addr(::std::uint64_t addr, bool is_write) noexcept; bool try_recv_addr(::std::uint64_t &addr, bool &is_write) noexcept; ::std::uint64_t get_cycle() const noexcept; ~SimpleDDR4() = delete; private: friend ::rust::layout; struct layout { static ::std::size_t size() noexcept; static ::std::size_t align() noexcept; }; }; #endif // CXXBRIDGE1_STRUCT_SimpleDDR4 extern "C" { ::std::size_t cxxbridge1$SimpleDDR4$operator$sizeof() noexcept; ::std::size_t cxxbridge1$SimpleDDR4$operator$alignof() noexcept; void cxxbridge1$init_logger() noexcept; ::SimpleDDR4 *cxxbridge1$new_ddr4(::rust::Str config) noexcept; void cxxbridge1$SimpleDDR4$tick_ddr4(::SimpleDDR4 &self) noexcept; bool cxxbridge1$SimpleDDR4$try_send_addr(::SimpleDDR4 &self, ::std::uint64_t addr, bool is_write) noexcept; bool cxxbridge1$SimpleDDR4$try_recv_addr(::SimpleDDR4 &self, ::std::uint64_t &addr, bool &is_write) noexcept; ::std::uint64_t cxxbridge1$SimpleDDR4$get_cycle(const ::SimpleDDR4 &self) noexcept; } // extern "C" ::std::size_t SimpleDDR4::layout::size() noexcept { return cxxbridge1$SimpleDDR4$operator$sizeof(); } ::std::size_t SimpleDDR4::layout::align() noexcept { return cxxbridge1$SimpleDDR4$operator$alignof(); } void init_logger() noexcept { cxxbridge1$init_logger(); } ::rust::Box<::SimpleDDR4> new_ddr4(::rust::Str config) noexcept { return ::rust::Box<::SimpleDDR4>::from_raw(cxxbridge1$new_ddr4(config)); } void SimpleDDR4::tick_ddr4() noexcept { cxxbridge1$SimpleDDR4$tick_ddr4(*this); } bool SimpleDDR4::try_send_addr(::std::uint64_t addr, bool is_write) noexcept { return cxxbridge1$SimpleDDR4$try_send_addr(*this, addr, is_write); } bool SimpleDDR4::try_recv_addr(::std::uint64_t &addr, bool &is_write) noexcept { return cxxbridge1$SimpleDDR4$try_recv_addr(*this, addr, is_write); } ::std::uint64_t SimpleDDR4::get_cycle() const noexcept { return cxxbridge1$SimpleDDR4$get_cycle(*this); } extern "C" { ::SimpleDDR4 *cxxbridge1$box$SimpleDDR4$alloc() noexcept; void cxxbridge1$box$SimpleDDR4$dealloc(::SimpleDDR4 *) noexcept; void cxxbridge1$box$SimpleDDR4$drop(::rust::Box<::SimpleDDR4> *ptr) noexcept; } // extern "C" namespace rust { inline namespace cxxbridge1 { template <> ::SimpleDDR4 *Box<::SimpleDDR4>::allocation::alloc() noexcept { return cxxbridge1$box$SimpleDDR4$alloc(); } template <> void Box<::SimpleDDR4>::allocation::dealloc(::SimpleDDR4 *ptr) noexcept { cxxbridge1$box$SimpleDDR4$dealloc(ptr); } template <> void Box<::SimpleDDR4>::drop() noexcept { cxxbridge1$box$SimpleDDR4$drop(this); } } // namespace cxxbridge1 } // namespace rust