1 #include "hal_names.hpp"
2 #include <algorithm>
3 #include <array>
4 #include <cassert>
5 #include <cstddef>
6 #include <cstdint>
7 #include <initializer_list>
8 #include <iterator>
9 #include <new>
10 #include <stdexcept>
11 #include <string>
12 #include <type_traits>
13 #include <utility>
14
15 namespace rust {
16 inline namespace cxxbridge1 {
17 // #include "rust/cxx.h"
18
19 #ifndef CXXBRIDGE1_PANIC
20 #define CXXBRIDGE1_PANIC
21 template <typename Exception>
22 void panic [[noreturn]] (const char *msg);
23 #endif // CXXBRIDGE1_PANIC
24
25 struct unsafe_bitcopy_t;
26
27 namespace {
28 template <typename T>
29 class impl;
30 } // namespace
31
32 class Opaque;
33
34 template <typename T>
35 ::std::size_t size_of();
36 template <typename T>
37 ::std::size_t align_of();
38
39 #ifndef CXXBRIDGE1_RUST_STRING
40 #define CXXBRIDGE1_RUST_STRING
41 class String final {
42 public:
43 String() noexcept;
44 String(const String &) noexcept;
45 String(String &&) noexcept;
46 ~String() noexcept;
47
48 String(const std::string &);
49 String(const char *);
50 String(const char *, std::size_t);
51 String(const char16_t *);
52 String(const char16_t *, std::size_t);
53
54 static String lossy(const std::string &) noexcept;
55 static String lossy(const char *) noexcept;
56 static String lossy(const char *, std::size_t) noexcept;
57 static String lossy(const char16_t *) noexcept;
58 static String lossy(const char16_t *, std::size_t) noexcept;
59
60 String &operator=(const String &) &noexcept;
61 String &operator=(String &&) &noexcept;
62
63 explicit operator std::string() const;
64
65 const char *data() const noexcept;
66 std::size_t size() const noexcept;
67 std::size_t length() const noexcept;
68 bool empty() const noexcept;
69
70 const char *c_str() noexcept;
71
72 std::size_t capacity() const noexcept;
73 void reserve(size_t new_cap) noexcept;
74
75 using iterator = char *;
76 iterator begin() noexcept;
77 iterator end() noexcept;
78
79 using const_iterator = const char *;
80 const_iterator begin() const noexcept;
81 const_iterator end() const noexcept;
82 const_iterator cbegin() const noexcept;
83 const_iterator cend() const noexcept;
84
85 bool operator==(const String &) const noexcept;
86 bool operator!=(const String &) const noexcept;
87 bool operator<(const String &) const noexcept;
88 bool operator<=(const String &) const noexcept;
89 bool operator>(const String &) const noexcept;
90 bool operator>=(const String &) const noexcept;
91
92 void swap(String &) noexcept;
93
94 String(unsafe_bitcopy_t, const String &) noexcept;
95
96 private:
97 struct lossy_t;
98 String(lossy_t, const char *, std::size_t) noexcept;
99 String(lossy_t, const char16_t *, std::size_t) noexcept;
swap(String & lhs,String & rhs)100 friend void swap(String &lhs, String &rhs) noexcept { lhs.swap(rhs); }
101
102 std::array<std::uintptr_t, 3> repr;
103 };
104 #endif // CXXBRIDGE1_RUST_STRING
105
106 #ifndef CXXBRIDGE1_RUST_STR
107 #define CXXBRIDGE1_RUST_STR
108 class Str final {
109 public:
110 Str() noexcept;
111 Str(const String &) noexcept;
112 Str(const std::string &);
113 Str(const char *);
114 Str(const char *, std::size_t);
115
116 Str &operator=(const Str &) &noexcept = default;
117
118 explicit operator std::string() const;
119
120 const char *data() const noexcept;
121 std::size_t size() const noexcept;
122 std::size_t length() const noexcept;
123 bool empty() const noexcept;
124
125 Str(const Str &) noexcept = default;
126 ~Str() noexcept = default;
127
128 using iterator = const char *;
129 using const_iterator = const char *;
130 const_iterator begin() const noexcept;
131 const_iterator end() const noexcept;
132 const_iterator cbegin() const noexcept;
133 const_iterator cend() const noexcept;
134
135 bool operator==(const Str &) const noexcept;
136 bool operator!=(const Str &) const noexcept;
137 bool operator<(const Str &) const noexcept;
138 bool operator<=(const Str &) const noexcept;
139 bool operator>(const Str &) const noexcept;
140 bool operator>=(const Str &) const noexcept;
141
142 void swap(Str &) noexcept;
143
144 private:
145 class uninit;
146 Str(uninit) noexcept;
147 friend impl<Str>;
148
149 std::array<std::uintptr_t, 2> repr;
150 };
151 #endif // CXXBRIDGE1_RUST_STR
152
153 #ifndef CXXBRIDGE1_RUST_SLICE
154 #define CXXBRIDGE1_RUST_SLICE
155 namespace detail {
156 template <bool>
157 struct copy_assignable_if {};
158
159 template <>
160 struct copy_assignable_if<false> {
161 copy_assignable_if() noexcept = default;
162 copy_assignable_if(const copy_assignable_if &) noexcept = default;
163 copy_assignable_if &operator=(const copy_assignable_if &) &noexcept = delete;
164 copy_assignable_if &operator=(copy_assignable_if &&) &noexcept = default;
165 };
166 } // namespace detail
167
168 template <typename T>
169 class Slice final
170 : private detail::copy_assignable_if<std::is_const<T>::value> {
171 public:
172 using value_type = T;
173
174 Slice() noexcept;
175 Slice(T *, std::size_t count) noexcept;
176
177 Slice &operator=(const Slice<T> &) &noexcept = default;
178 Slice &operator=(Slice<T> &&) &noexcept = default;
179
180 T *data() const noexcept;
181 std::size_t size() const noexcept;
182 std::size_t length() const noexcept;
183 bool empty() const noexcept;
184
185 T &operator[](std::size_t n) const noexcept;
186 T &at(std::size_t n) const;
187 T &front() const noexcept;
188 T &back() const noexcept;
189
190 Slice(const Slice<T> &) noexcept = default;
191 ~Slice() noexcept = default;
192
193 class iterator;
194 iterator begin() const noexcept;
195 iterator end() const noexcept;
196
197 void swap(Slice &) noexcept;
198
199 private:
200 class uninit;
201 Slice(uninit) noexcept;
202 friend impl<Slice>;
203 friend void sliceInit(void *, const void *, std::size_t) noexcept;
204 friend void *slicePtr(const void *) noexcept;
205 friend std::size_t sliceLen(const void *) noexcept;
206
207 std::array<std::uintptr_t, 2> repr;
208 };
209
210 template <typename T>
211 class Slice<T>::iterator final {
212 public:
213 using iterator_category = std::random_access_iterator_tag;
214 using value_type = T;
215 using difference_type = std::ptrdiff_t;
216 using pointer = typename std::add_pointer<T>::type;
217 using reference = typename std::add_lvalue_reference<T>::type;
218
219 reference operator*() const noexcept;
220 pointer operator->() const noexcept;
221 reference operator[](difference_type) const noexcept;
222
223 iterator &operator++() noexcept;
224 iterator operator++(int) noexcept;
225 iterator &operator--() noexcept;
226 iterator operator--(int) noexcept;
227
228 iterator &operator+=(difference_type) noexcept;
229 iterator &operator-=(difference_type) noexcept;
230 iterator operator+(difference_type) const noexcept;
231 iterator operator-(difference_type) const noexcept;
232 difference_type operator-(const iterator &) const noexcept;
233
234 bool operator==(const iterator &) const noexcept;
235 bool operator!=(const iterator &) const noexcept;
236 bool operator<(const iterator &) const noexcept;
237 bool operator<=(const iterator &) const noexcept;
238 bool operator>(const iterator &) const noexcept;
239 bool operator>=(const iterator &) const noexcept;
240
241 private:
242 friend class Slice;
243 void *pos;
244 std::size_t stride;
245 };
246
247 template <typename T>
Slice()248 Slice<T>::Slice() noexcept {
249 sliceInit(this, reinterpret_cast<void *>(align_of<T>()), 0);
250 }
251
252 template <typename T>
Slice(T * s,std::size_t count)253 Slice<T>::Slice(T *s, std::size_t count) noexcept {
254 assert(s != nullptr || count == 0);
255 sliceInit(this,
256 s == nullptr && count == 0
257 ? reinterpret_cast<void *>(align_of<T>())
258 : const_cast<typename std::remove_const<T>::type *>(s),
259 count);
260 }
261
262 template <typename T>
data() const263 T *Slice<T>::data() const noexcept {
264 return reinterpret_cast<T *>(slicePtr(this));
265 }
266
267 template <typename T>
size() const268 std::size_t Slice<T>::size() const noexcept {
269 return sliceLen(this);
270 }
271
272 template <typename T>
length() const273 std::size_t Slice<T>::length() const noexcept {
274 return this->size();
275 }
276
277 template <typename T>
empty() const278 bool Slice<T>::empty() const noexcept {
279 return this->size() == 0;
280 }
281
282 template <typename T>
operator [](std::size_t n) const283 T &Slice<T>::operator[](std::size_t n) const noexcept {
284 assert(n < this->size());
285 auto ptr = static_cast<char *>(slicePtr(this)) + size_of<T>() * n;
286 return *reinterpret_cast<T *>(ptr);
287 }
288
289 template <typename T>
at(std::size_t n) const290 T &Slice<T>::at(std::size_t n) const {
291 if (n >= this->size()) {
292 panic<std::out_of_range>("rust::Slice index out of range");
293 }
294 return (*this)[n];
295 }
296
297 template <typename T>
front() const298 T &Slice<T>::front() const noexcept {
299 assert(!this->empty());
300 return (*this)[0];
301 }
302
303 template <typename T>
back() const304 T &Slice<T>::back() const noexcept {
305 assert(!this->empty());
306 return (*this)[this->size() - 1];
307 }
308
309 template <typename T>
310 typename Slice<T>::iterator::reference
operator *() const311 Slice<T>::iterator::operator*() const noexcept {
312 return *static_cast<T *>(this->pos);
313 }
314
315 template <typename T>
316 typename Slice<T>::iterator::pointer
operator ->() const317 Slice<T>::iterator::operator->() const noexcept {
318 return static_cast<T *>(this->pos);
319 }
320
321 template <typename T>
operator [](typename Slice<T>::iterator::difference_type n) const322 typename Slice<T>::iterator::reference Slice<T>::iterator::operator[](
323 typename Slice<T>::iterator::difference_type n) const noexcept {
324 auto ptr = static_cast<char *>(this->pos) + this->stride * n;
325 return *reinterpret_cast<T *>(ptr);
326 }
327
328 template <typename T>
operator ++()329 typename Slice<T>::iterator &Slice<T>::iterator::operator++() noexcept {
330 this->pos = static_cast<char *>(this->pos) + this->stride;
331 return *this;
332 }
333
334 template <typename T>
operator ++(int)335 typename Slice<T>::iterator Slice<T>::iterator::operator++(int) noexcept {
336 auto ret = iterator(*this);
337 this->pos = static_cast<char *>(this->pos) + this->stride;
338 return ret;
339 }
340
341 template <typename T>
operator --()342 typename Slice<T>::iterator &Slice<T>::iterator::operator--() noexcept {
343 this->pos = static_cast<char *>(this->pos) - this->stride;
344 return *this;
345 }
346
347 template <typename T>
operator --(int)348 typename Slice<T>::iterator Slice<T>::iterator::operator--(int) noexcept {
349 auto ret = iterator(*this);
350 this->pos = static_cast<char *>(this->pos) - this->stride;
351 return ret;
352 }
353
354 template <typename T>
operator +=(typename Slice<T>::iterator::difference_type n)355 typename Slice<T>::iterator &Slice<T>::iterator::operator+=(
356 typename Slice<T>::iterator::difference_type n) noexcept {
357 this->pos = static_cast<char *>(this->pos) + this->stride * n;
358 return *this;
359 }
360
361 template <typename T>
operator -=(typename Slice<T>::iterator::difference_type n)362 typename Slice<T>::iterator &Slice<T>::iterator::operator-=(
363 typename Slice<T>::iterator::difference_type n) noexcept {
364 this->pos = static_cast<char *>(this->pos) - this->stride * n;
365 return *this;
366 }
367
368 template <typename T>
operator +(typename Slice<T>::iterator::difference_type n) const369 typename Slice<T>::iterator Slice<T>::iterator::operator+(
370 typename Slice<T>::iterator::difference_type n) const noexcept {
371 auto ret = iterator(*this);
372 ret.pos = static_cast<char *>(this->pos) + this->stride * n;
373 return ret;
374 }
375
376 template <typename T>
operator -(typename Slice<T>::iterator::difference_type n) const377 typename Slice<T>::iterator Slice<T>::iterator::operator-(
378 typename Slice<T>::iterator::difference_type n) const noexcept {
379 auto ret = iterator(*this);
380 ret.pos = static_cast<char *>(this->pos) - this->stride * n;
381 return ret;
382 }
383
384 template <typename T>
385 typename Slice<T>::iterator::difference_type
operator -(const iterator & other) const386 Slice<T>::iterator::operator-(const iterator &other) const noexcept {
387 auto diff = std::distance(static_cast<char *>(other.pos),
388 static_cast<char *>(this->pos));
389 return diff / static_cast<typename Slice<T>::iterator::difference_type>(
390 this->stride);
391 }
392
393 template <typename T>
operator ==(const iterator & other) const394 bool Slice<T>::iterator::operator==(const iterator &other) const noexcept {
395 return this->pos == other.pos;
396 }
397
398 template <typename T>
operator !=(const iterator & other) const399 bool Slice<T>::iterator::operator!=(const iterator &other) const noexcept {
400 return this->pos != other.pos;
401 }
402
403 template <typename T>
operator <(const iterator & other) const404 bool Slice<T>::iterator::operator<(const iterator &other) const noexcept {
405 return this->pos < other.pos;
406 }
407
408 template <typename T>
operator <=(const iterator & other) const409 bool Slice<T>::iterator::operator<=(const iterator &other) const noexcept {
410 return this->pos <= other.pos;
411 }
412
413 template <typename T>
operator >(const iterator & other) const414 bool Slice<T>::iterator::operator>(const iterator &other) const noexcept {
415 return this->pos > other.pos;
416 }
417
418 template <typename T>
operator >=(const iterator & other) const419 bool Slice<T>::iterator::operator>=(const iterator &other) const noexcept {
420 return this->pos >= other.pos;
421 }
422
423 template <typename T>
begin() const424 typename Slice<T>::iterator Slice<T>::begin() const noexcept {
425 iterator it;
426 it.pos = slicePtr(this);
427 it.stride = size_of<T>();
428 return it;
429 }
430
431 template <typename T>
end() const432 typename Slice<T>::iterator Slice<T>::end() const noexcept {
433 iterator it = this->begin();
434 it.pos = static_cast<char *>(it.pos) + it.stride * this->size();
435 return it;
436 }
437
438 template <typename T>
swap(Slice & rhs)439 void Slice<T>::swap(Slice &rhs) noexcept {
440 std::swap(*this, rhs);
441 }
442 #endif // CXXBRIDGE1_RUST_SLICE
443
444 #ifndef CXXBRIDGE1_RUST_BITCOPY_T
445 #define CXXBRIDGE1_RUST_BITCOPY_T
446 struct unsafe_bitcopy_t final {
447 explicit unsafe_bitcopy_t() = default;
448 };
449 #endif // CXXBRIDGE1_RUST_BITCOPY_T
450
451 #ifndef CXXBRIDGE1_RUST_VEC
452 #define CXXBRIDGE1_RUST_VEC
453 template <typename T>
454 class Vec final {
455 public:
456 using value_type = T;
457
458 Vec() noexcept;
459 Vec(std::initializer_list<T>);
460 Vec(const Vec &);
461 Vec(Vec &&) noexcept;
462 ~Vec() noexcept;
463
464 Vec &operator=(Vec &&) &noexcept;
465 Vec &operator=(const Vec &) &;
466
467 std::size_t size() const noexcept;
468 bool empty() const noexcept;
469 const T *data() const noexcept;
470 T *data() noexcept;
471 std::size_t capacity() const noexcept;
472
473 const T &operator[](std::size_t n) const noexcept;
474 const T &at(std::size_t n) const;
475 const T &front() const noexcept;
476 const T &back() const noexcept;
477
478 T &operator[](std::size_t n) noexcept;
479 T &at(std::size_t n);
480 T &front() noexcept;
481 T &back() noexcept;
482
483 void reserve(std::size_t new_cap);
484 void push_back(const T &value);
485 void push_back(T &&value);
486 template <typename... Args>
487 void emplace_back(Args &&...args);
488 void truncate(std::size_t len);
489 void clear();
490
491 using iterator = typename Slice<T>::iterator;
492 iterator begin() noexcept;
493 iterator end() noexcept;
494
495 using const_iterator = typename Slice<const T>::iterator;
496 const_iterator begin() const noexcept;
497 const_iterator end() const noexcept;
498 const_iterator cbegin() const noexcept;
499 const_iterator cend() const noexcept;
500
501 void swap(Vec &) noexcept;
502
503 Vec(unsafe_bitcopy_t, const Vec &) noexcept;
504
505 private:
506 void reserve_total(std::size_t new_cap) noexcept;
507 void set_len(std::size_t len) noexcept;
508 void drop() noexcept;
509
swap(Vec & lhs,Vec & rhs)510 friend void swap(Vec &lhs, Vec &rhs) noexcept { lhs.swap(rhs); }
511
512 std::array<std::uintptr_t, 3> repr;
513 };
514
515 template <typename T>
Vec(std::initializer_list<T> init)516 Vec<T>::Vec(std::initializer_list<T> init) : Vec{} {
517 this->reserve_total(init.size());
518 std::move(init.begin(), init.end(), std::back_inserter(*this));
519 }
520
521 template <typename T>
Vec(const Vec & other)522 Vec<T>::Vec(const Vec &other) : Vec() {
523 this->reserve_total(other.size());
524 std::copy(other.begin(), other.end(), std::back_inserter(*this));
525 }
526
527 template <typename T>
Vec(Vec && other)528 Vec<T>::Vec(Vec &&other) noexcept : repr(other.repr) {
529 new (&other) Vec();
530 }
531
532 template <typename T>
~Vec()533 Vec<T>::~Vec() noexcept {
534 this->drop();
535 }
536
537 template <typename T>
operator =(Vec && other)538 Vec<T> &Vec<T>::operator=(Vec &&other) &noexcept {
539 this->drop();
540 this->repr = other.repr;
541 new (&other) Vec();
542 return *this;
543 }
544
545 template <typename T>
operator =(const Vec & other)546 Vec<T> &Vec<T>::operator=(const Vec &other) & {
547 if (this != &other) {
548 this->drop();
549 new (this) Vec(other);
550 }
551 return *this;
552 }
553
554 template <typename T>
empty() const555 bool Vec<T>::empty() const noexcept {
556 return this->size() == 0;
557 }
558
559 template <typename T>
data()560 T *Vec<T>::data() noexcept {
561 return const_cast<T *>(const_cast<const Vec<T> *>(this)->data());
562 }
563
564 template <typename T>
operator [](std::size_t n) const565 const T &Vec<T>::operator[](std::size_t n) const noexcept {
566 assert(n < this->size());
567 auto data = reinterpret_cast<const char *>(this->data());
568 return *reinterpret_cast<const T *>(data + n * size_of<T>());
569 }
570
571 template <typename T>
at(std::size_t n) const572 const T &Vec<T>::at(std::size_t n) const {
573 if (n >= this->size()) {
574 panic<std::out_of_range>("rust::Vec index out of range");
575 }
576 return (*this)[n];
577 }
578
579 template <typename T>
front() const580 const T &Vec<T>::front() const noexcept {
581 assert(!this->empty());
582 return (*this)[0];
583 }
584
585 template <typename T>
back() const586 const T &Vec<T>::back() const noexcept {
587 assert(!this->empty());
588 return (*this)[this->size() - 1];
589 }
590
591 template <typename T>
operator [](std::size_t n)592 T &Vec<T>::operator[](std::size_t n) noexcept {
593 assert(n < this->size());
594 auto data = reinterpret_cast<char *>(this->data());
595 return *reinterpret_cast<T *>(data + n * size_of<T>());
596 }
597
598 template <typename T>
at(std::size_t n)599 T &Vec<T>::at(std::size_t n) {
600 if (n >= this->size()) {
601 panic<std::out_of_range>("rust::Vec index out of range");
602 }
603 return (*this)[n];
604 }
605
606 template <typename T>
front()607 T &Vec<T>::front() noexcept {
608 assert(!this->empty());
609 return (*this)[0];
610 }
611
612 template <typename T>
back()613 T &Vec<T>::back() noexcept {
614 assert(!this->empty());
615 return (*this)[this->size() - 1];
616 }
617
618 template <typename T>
reserve(std::size_t new_cap)619 void Vec<T>::reserve(std::size_t new_cap) {
620 this->reserve_total(new_cap);
621 }
622
623 template <typename T>
push_back(const T & value)624 void Vec<T>::push_back(const T &value) {
625 this->emplace_back(value);
626 }
627
628 template <typename T>
push_back(T && value)629 void Vec<T>::push_back(T &&value) {
630 this->emplace_back(std::move(value));
631 }
632
633 template <typename T>
634 template <typename... Args>
emplace_back(Args &&...args)635 void Vec<T>::emplace_back(Args &&...args) {
636 auto size = this->size();
637 this->reserve_total(size + 1);
638 ::new (reinterpret_cast<T *>(reinterpret_cast<char *>(this->data()) +
639 size * size_of<T>()))
640 T(std::forward<Args>(args)...);
641 this->set_len(size + 1);
642 }
643
644 template <typename T>
clear()645 void Vec<T>::clear() {
646 this->truncate(0);
647 }
648
649 template <typename T>
begin()650 typename Vec<T>::iterator Vec<T>::begin() noexcept {
651 return Slice<T>(this->data(), this->size()).begin();
652 }
653
654 template <typename T>
end()655 typename Vec<T>::iterator Vec<T>::end() noexcept {
656 return Slice<T>(this->data(), this->size()).end();
657 }
658
659 template <typename T>
begin() const660 typename Vec<T>::const_iterator Vec<T>::begin() const noexcept {
661 return this->cbegin();
662 }
663
664 template <typename T>
end() const665 typename Vec<T>::const_iterator Vec<T>::end() const noexcept {
666 return this->cend();
667 }
668
669 template <typename T>
cbegin() const670 typename Vec<T>::const_iterator Vec<T>::cbegin() const noexcept {
671 return Slice<const T>(this->data(), this->size()).begin();
672 }
673
674 template <typename T>
cend() const675 typename Vec<T>::const_iterator Vec<T>::cend() const noexcept {
676 return Slice<const T>(this->data(), this->size()).end();
677 }
678
679 template <typename T>
swap(Vec & rhs)680 void Vec<T>::swap(Vec &rhs) noexcept {
681 using std::swap;
682 swap(this->repr, rhs.repr);
683 }
684
685 template <typename T>
Vec(unsafe_bitcopy_t,const Vec & bits)686 Vec<T>::Vec(unsafe_bitcopy_t, const Vec &bits) noexcept : repr(bits.repr) {}
687 #endif // CXXBRIDGE1_RUST_VEC
688
689 #ifndef CXXBRIDGE1_IS_COMPLETE
690 #define CXXBRIDGE1_IS_COMPLETE
691 namespace detail {
692 namespace {
693 template <typename T, typename = std::size_t>
694 struct is_complete : std::false_type {};
695 template <typename T>
696 struct is_complete<T, decltype(sizeof(T))> : std::true_type {};
697 } // namespace
698 } // namespace detail
699 #endif // CXXBRIDGE1_IS_COMPLETE
700
701 #ifndef CXXBRIDGE1_LAYOUT
702 #define CXXBRIDGE1_LAYOUT
703 class layout {
704 template <typename T>
705 friend std::size_t size_of();
706 template <typename T>
707 friend std::size_t align_of();
708 template <typename T>
709 static typename std::enable_if<std::is_base_of<Opaque, T>::value,
710 std::size_t>::type
do_size_of()711 do_size_of() {
712 return T::layout::size();
713 }
714 template <typename T>
715 static typename std::enable_if<!std::is_base_of<Opaque, T>::value,
716 std::size_t>::type
do_size_of()717 do_size_of() {
718 return sizeof(T);
719 }
720 template <typename T>
721 static
722 typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type
size_of()723 size_of() {
724 return do_size_of<T>();
725 }
726 template <typename T>
727 static typename std::enable_if<std::is_base_of<Opaque, T>::value,
728 std::size_t>::type
do_align_of()729 do_align_of() {
730 return T::layout::align();
731 }
732 template <typename T>
733 static typename std::enable_if<!std::is_base_of<Opaque, T>::value,
734 std::size_t>::type
do_align_of()735 do_align_of() {
736 return alignof(T);
737 }
738 template <typename T>
739 static
740 typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type
align_of()741 align_of() {
742 return do_align_of<T>();
743 }
744 };
745
746 template <typename T>
size_of()747 std::size_t size_of() {
748 return layout::size_of<T>();
749 }
750
751 template <typename T>
align_of()752 std::size_t align_of() {
753 return layout::align_of<T>();
754 }
755 #endif // CXXBRIDGE1_LAYOUT
756 } // namespace cxxbridge1
757 } // namespace rust
758
759 extern "C" {
cxxbridge1$get_hidl_instances(::rust::Str package,::std::size_t major_version,::std::size_t minor_version,::rust::Str interface_name,::rust::Vec<::rust::String> * return$)760 void cxxbridge1$get_hidl_instances(::rust::Str package, ::std::size_t major_version, ::std::size_t minor_version, ::rust::Str interface_name, ::rust::Vec<::rust::String> *return$) noexcept {
761 ::rust::Vec<::rust::String> (*get_hidl_instances$)(::rust::Str, ::std::size_t, ::std::size_t, ::rust::Str) = ::get_hidl_instances;
762 new (return$) ::rust::Vec<::rust::String>(get_hidl_instances$(package, major_version, minor_version, interface_name));
763 }
764 } // extern "C"
765