1 #include "ffi/FromRustToCpp.h"
2 #include <array>
3 #include <cassert>
4 #include <cstddef>
5 #include <cstdint>
6 #include <functional>
7 #include <iterator>
8 #include <new>
9 #include <stdexcept>
10 #include <string>
11 #include <type_traits>
12 #include <utility>
13 
14 namespace rust {
15 inline namespace cxxbridge1 {
16 // #include "rust/cxx.h"
17 
18 #ifndef CXXBRIDGE1_PANIC
19 #define CXXBRIDGE1_PANIC
20 template <typename Exception>
21 void panic [[noreturn]] (const char *msg);
22 #endif // CXXBRIDGE1_PANIC
23 
24 struct unsafe_bitcopy_t;
25 
26 namespace {
27 template <typename T>
28 class impl;
29 } // namespace
30 
31 template <typename T>
32 ::std::size_t size_of();
33 template <typename T>
34 ::std::size_t align_of();
35 
36 #ifndef CXXBRIDGE1_RUST_STRING
37 #define CXXBRIDGE1_RUST_STRING
38 class String final {
39 public:
40   String() noexcept;
41   String(const String &) noexcept;
42   String(String &&) noexcept;
43   ~String() noexcept;
44 
45   String(const std::string &);
46   String(const char *);
47   String(const char *, std::size_t);
48   String(const char16_t *);
49   String(const char16_t *, std::size_t);
50 
51   static String lossy(const std::string &) noexcept;
52   static String lossy(const char *) noexcept;
53   static String lossy(const char *, std::size_t) noexcept;
54   static String lossy(const char16_t *) noexcept;
55   static String lossy(const char16_t *, std::size_t) noexcept;
56 
57   String &operator=(const String &) &noexcept;
58   String &operator=(String &&) &noexcept;
59 
60   explicit operator std::string() const;
61 
62   const char *data() const noexcept;
63   std::size_t size() const noexcept;
64   std::size_t length() const noexcept;
65   bool empty() const noexcept;
66 
67   const char *c_str() noexcept;
68 
69   std::size_t capacity() const noexcept;
70   void reserve(size_t new_cap) noexcept;
71 
72   using iterator = char *;
73   iterator begin() noexcept;
74   iterator end() noexcept;
75 
76   using const_iterator = const char *;
77   const_iterator begin() const noexcept;
78   const_iterator end() const noexcept;
79   const_iterator cbegin() const noexcept;
80   const_iterator cend() const noexcept;
81 
82   bool operator==(const String &) const noexcept;
83   bool operator!=(const String &) const noexcept;
84   bool operator<(const String &) const noexcept;
85   bool operator<=(const String &) const noexcept;
86   bool operator>(const String &) const noexcept;
87   bool operator>=(const String &) const noexcept;
88 
89   void swap(String &) noexcept;
90 
91   String(unsafe_bitcopy_t, const String &) noexcept;
92 
93 private:
94   struct lossy_t;
95   String(lossy_t, const char *, std::size_t) noexcept;
96   String(lossy_t, const char16_t *, std::size_t) noexcept;
swap(String & lhs,String & rhs)97   friend void swap(String &lhs, String &rhs) noexcept { lhs.swap(rhs); }
98 
99   std::array<std::uintptr_t, 3> repr;
100 };
101 #endif // CXXBRIDGE1_RUST_STRING
102 
103 #ifndef CXXBRIDGE1_RUST_STR
104 #define CXXBRIDGE1_RUST_STR
105 class Str final {
106 public:
107   Str() noexcept;
108   Str(const String &) noexcept;
109   Str(const std::string &);
110   Str(const char *);
111   Str(const char *, std::size_t);
112 
113   Str &operator=(const Str &) &noexcept = default;
114 
115   explicit operator std::string() const;
116 
117   const char *data() const noexcept;
118   std::size_t size() const noexcept;
119   std::size_t length() const noexcept;
120   bool empty() const noexcept;
121 
122   Str(const Str &) noexcept = default;
123   ~Str() noexcept = default;
124 
125   using iterator = const char *;
126   using const_iterator = const char *;
127   const_iterator begin() const noexcept;
128   const_iterator end() const noexcept;
129   const_iterator cbegin() const noexcept;
130   const_iterator cend() const noexcept;
131 
132   bool operator==(const Str &) const noexcept;
133   bool operator!=(const Str &) const noexcept;
134   bool operator<(const Str &) const noexcept;
135   bool operator<=(const Str &) const noexcept;
136   bool operator>(const Str &) const noexcept;
137   bool operator>=(const Str &) const noexcept;
138 
139   void swap(Str &) noexcept;
140 
141 private:
142   class uninit;
143   Str(uninit) noexcept;
144   friend impl<Str>;
145 
146   std::array<std::uintptr_t, 2> repr;
147 };
148 #endif // CXXBRIDGE1_RUST_STR
149 
150 #ifndef CXXBRIDGE1_RUST_SLICE
151 #define CXXBRIDGE1_RUST_SLICE
152 namespace detail {
153 template <bool>
154 struct copy_assignable_if {};
155 
156 template <>
157 struct copy_assignable_if<false> {
158   copy_assignable_if() noexcept = default;
159   copy_assignable_if(const copy_assignable_if &) noexcept = default;
160   copy_assignable_if &operator=(const copy_assignable_if &) &noexcept = delete;
161   copy_assignable_if &operator=(copy_assignable_if &&) &noexcept = default;
162 };
163 } // namespace detail
164 
165 template <typename T>
166 class Slice final
167     : private detail::copy_assignable_if<std::is_const<T>::value> {
168 public:
169   using value_type = T;
170 
171   Slice() noexcept;
172   Slice(T *, std::size_t count) noexcept;
173 
174   Slice &operator=(const Slice<T> &) &noexcept = default;
175   Slice &operator=(Slice<T> &&) &noexcept = default;
176 
177   T *data() const noexcept;
178   std::size_t size() const noexcept;
179   std::size_t length() const noexcept;
180   bool empty() const noexcept;
181 
182   T &operator[](std::size_t n) const noexcept;
183   T &at(std::size_t n) const;
184   T &front() const noexcept;
185   T &back() const noexcept;
186 
187   Slice(const Slice<T> &) noexcept = default;
188   ~Slice() noexcept = default;
189 
190   class iterator;
191   iterator begin() const noexcept;
192   iterator end() const noexcept;
193 
194   void swap(Slice &) noexcept;
195 
196 private:
197   class uninit;
198   Slice(uninit) noexcept;
199   friend impl<Slice>;
200   friend void sliceInit(void *, const void *, std::size_t) noexcept;
201   friend void *slicePtr(const void *) noexcept;
202   friend std::size_t sliceLen(const void *) noexcept;
203 
204   std::array<std::uintptr_t, 2> repr;
205 };
206 
207 template <typename T>
208 class Slice<T>::iterator final {
209 public:
210   using iterator_category = std::random_access_iterator_tag;
211   using value_type = T;
212   using difference_type = std::ptrdiff_t;
213   using pointer = typename std::add_pointer<T>::type;
214   using reference = typename std::add_lvalue_reference<T>::type;
215 
216   reference operator*() const noexcept;
217   pointer operator->() const noexcept;
218   reference operator[](difference_type) const noexcept;
219 
220   iterator &operator++() noexcept;
221   iterator operator++(int) noexcept;
222   iterator &operator--() noexcept;
223   iterator operator--(int) noexcept;
224 
225   iterator &operator+=(difference_type) noexcept;
226   iterator &operator-=(difference_type) noexcept;
227   iterator operator+(difference_type) const noexcept;
228   iterator operator-(difference_type) const noexcept;
229   difference_type operator-(const iterator &) const noexcept;
230 
231   bool operator==(const iterator &) const noexcept;
232   bool operator!=(const iterator &) const noexcept;
233   bool operator<(const iterator &) const noexcept;
234   bool operator<=(const iterator &) const noexcept;
235   bool operator>(const iterator &) const noexcept;
236   bool operator>=(const iterator &) const noexcept;
237 
238 private:
239   friend class Slice;
240   void *pos;
241   std::size_t stride;
242 };
243 
244 template <typename T>
Slice()245 Slice<T>::Slice() noexcept {
246   sliceInit(this, reinterpret_cast<void *>(align_of<T>()), 0);
247 }
248 
249 template <typename T>
Slice(T * s,std::size_t count)250 Slice<T>::Slice(T *s, std::size_t count) noexcept {
251   assert(s != nullptr || count == 0);
252   sliceInit(this,
253             s == nullptr && count == 0
254                 ? reinterpret_cast<void *>(align_of<T>())
255                 : const_cast<typename std::remove_const<T>::type *>(s),
256             count);
257 }
258 
259 template <typename T>
data() const260 T *Slice<T>::data() const noexcept {
261   return reinterpret_cast<T *>(slicePtr(this));
262 }
263 
264 template <typename T>
size() const265 std::size_t Slice<T>::size() const noexcept {
266   return sliceLen(this);
267 }
268 
269 template <typename T>
length() const270 std::size_t Slice<T>::length() const noexcept {
271   return this->size();
272 }
273 
274 template <typename T>
empty() const275 bool Slice<T>::empty() const noexcept {
276   return this->size() == 0;
277 }
278 
279 template <typename T>
operator [](std::size_t n) const280 T &Slice<T>::operator[](std::size_t n) const noexcept {
281   assert(n < this->size());
282   auto ptr = static_cast<char *>(slicePtr(this)) + size_of<T>() * n;
283   return *reinterpret_cast<T *>(ptr);
284 }
285 
286 template <typename T>
at(std::size_t n) const287 T &Slice<T>::at(std::size_t n) const {
288   if (n >= this->size()) {
289     panic<std::out_of_range>("rust::Slice index out of range");
290   }
291   return (*this)[n];
292 }
293 
294 template <typename T>
front() const295 T &Slice<T>::front() const noexcept {
296   assert(!this->empty());
297   return (*this)[0];
298 }
299 
300 template <typename T>
back() const301 T &Slice<T>::back() const noexcept {
302   assert(!this->empty());
303   return (*this)[this->size() - 1];
304 }
305 
306 template <typename T>
307 typename Slice<T>::iterator::reference
operator *() const308 Slice<T>::iterator::operator*() const noexcept {
309   return *static_cast<T *>(this->pos);
310 }
311 
312 template <typename T>
313 typename Slice<T>::iterator::pointer
operator ->() const314 Slice<T>::iterator::operator->() const noexcept {
315   return static_cast<T *>(this->pos);
316 }
317 
318 template <typename T>
operator [](typename Slice<T>::iterator::difference_type n) const319 typename Slice<T>::iterator::reference Slice<T>::iterator::operator[](
320     typename Slice<T>::iterator::difference_type n) const noexcept {
321   auto ptr = static_cast<char *>(this->pos) + this->stride * n;
322   return *reinterpret_cast<T *>(ptr);
323 }
324 
325 template <typename T>
operator ++()326 typename Slice<T>::iterator &Slice<T>::iterator::operator++() noexcept {
327   this->pos = static_cast<char *>(this->pos) + this->stride;
328   return *this;
329 }
330 
331 template <typename T>
operator ++(int)332 typename Slice<T>::iterator Slice<T>::iterator::operator++(int) noexcept {
333   auto ret = iterator(*this);
334   this->pos = static_cast<char *>(this->pos) + this->stride;
335   return ret;
336 }
337 
338 template <typename T>
operator --()339 typename Slice<T>::iterator &Slice<T>::iterator::operator--() noexcept {
340   this->pos = static_cast<char *>(this->pos) - this->stride;
341   return *this;
342 }
343 
344 template <typename T>
operator --(int)345 typename Slice<T>::iterator Slice<T>::iterator::operator--(int) noexcept {
346   auto ret = iterator(*this);
347   this->pos = static_cast<char *>(this->pos) - this->stride;
348   return ret;
349 }
350 
351 template <typename T>
operator +=(typename Slice<T>::iterator::difference_type n)352 typename Slice<T>::iterator &Slice<T>::iterator::operator+=(
353     typename Slice<T>::iterator::difference_type n) noexcept {
354   this->pos = static_cast<char *>(this->pos) + this->stride * n;
355   return *this;
356 }
357 
358 template <typename T>
operator -=(typename Slice<T>::iterator::difference_type n)359 typename Slice<T>::iterator &Slice<T>::iterator::operator-=(
360     typename Slice<T>::iterator::difference_type n) noexcept {
361   this->pos = static_cast<char *>(this->pos) - this->stride * n;
362   return *this;
363 }
364 
365 template <typename T>
operator +(typename Slice<T>::iterator::difference_type n) const366 typename Slice<T>::iterator Slice<T>::iterator::operator+(
367     typename Slice<T>::iterator::difference_type n) const noexcept {
368   auto ret = iterator(*this);
369   ret.pos = static_cast<char *>(this->pos) + this->stride * n;
370   return ret;
371 }
372 
373 template <typename T>
operator -(typename Slice<T>::iterator::difference_type n) const374 typename Slice<T>::iterator Slice<T>::iterator::operator-(
375     typename Slice<T>::iterator::difference_type n) const noexcept {
376   auto ret = iterator(*this);
377   ret.pos = static_cast<char *>(this->pos) - this->stride * n;
378   return ret;
379 }
380 
381 template <typename T>
382 typename Slice<T>::iterator::difference_type
operator -(const iterator & other) const383 Slice<T>::iterator::operator-(const iterator &other) const noexcept {
384   auto diff = std::distance(static_cast<char *>(other.pos),
385                             static_cast<char *>(this->pos));
386   return diff / static_cast<typename Slice<T>::iterator::difference_type>(
387                     this->stride);
388 }
389 
390 template <typename T>
operator ==(const iterator & other) const391 bool Slice<T>::iterator::operator==(const iterator &other) const noexcept {
392   return this->pos == other.pos;
393 }
394 
395 template <typename T>
operator !=(const iterator & other) const396 bool Slice<T>::iterator::operator!=(const iterator &other) const noexcept {
397   return this->pos != other.pos;
398 }
399 
400 template <typename T>
operator <(const iterator & other) const401 bool Slice<T>::iterator::operator<(const iterator &other) const noexcept {
402   return this->pos < other.pos;
403 }
404 
405 template <typename T>
operator <=(const iterator & other) const406 bool Slice<T>::iterator::operator<=(const iterator &other) const noexcept {
407   return this->pos <= other.pos;
408 }
409 
410 template <typename T>
operator >(const iterator & other) const411 bool Slice<T>::iterator::operator>(const iterator &other) const noexcept {
412   return this->pos > other.pos;
413 }
414 
415 template <typename T>
operator >=(const iterator & other) const416 bool Slice<T>::iterator::operator>=(const iterator &other) const noexcept {
417   return this->pos >= other.pos;
418 }
419 
420 template <typename T>
begin() const421 typename Slice<T>::iterator Slice<T>::begin() const noexcept {
422   iterator it;
423   it.pos = slicePtr(this);
424   it.stride = size_of<T>();
425   return it;
426 }
427 
428 template <typename T>
end() const429 typename Slice<T>::iterator Slice<T>::end() const noexcept {
430   iterator it = this->begin();
431   it.pos = static_cast<char *>(it.pos) + it.stride * this->size();
432   return it;
433 }
434 
435 template <typename T>
swap(Slice & rhs)436 void Slice<T>::swap(Slice &rhs) noexcept {
437   std::swap(*this, rhs);
438 }
439 #endif // CXXBRIDGE1_RUST_SLICE
440 
441 #ifndef CXXBRIDGE1_RUST_BOX
442 #define CXXBRIDGE1_RUST_BOX
443 template <typename T>
444 class Box final {
445 public:
446   using element_type = T;
447   using const_pointer =
448       typename std::add_pointer<typename std::add_const<T>::type>::type;
449   using pointer = typename std::add_pointer<T>::type;
450 
451   Box() = delete;
452   Box(Box &&) noexcept;
453   ~Box() noexcept;
454 
455   explicit Box(const T &);
456   explicit Box(T &&);
457 
458   Box &operator=(Box &&) &noexcept;
459 
460   const T *operator->() const noexcept;
461   const T &operator*() const noexcept;
462   T *operator->() noexcept;
463   T &operator*() noexcept;
464 
465   template <typename... Fields>
466   static Box in_place(Fields &&...);
467 
468   void swap(Box &) noexcept;
469 
470   static Box from_raw(T *) noexcept;
471 
472   T *into_raw() noexcept;
473 
474   /* Deprecated */ using value_type = element_type;
475 
476 private:
477   class uninit;
478   class allocation;
479   Box(uninit) noexcept;
480   void drop() noexcept;
481 
swap(Box & lhs,Box & rhs)482   friend void swap(Box &lhs, Box &rhs) noexcept { lhs.swap(rhs); }
483 
484   T *ptr;
485 };
486 
487 template <typename T>
488 class Box<T>::uninit {};
489 
490 template <typename T>
491 class Box<T>::allocation {
492   static T *alloc() noexcept;
493   static void dealloc(T *) noexcept;
494 
495 public:
allocation()496   allocation() noexcept : ptr(alloc()) {}
~allocation()497   ~allocation() noexcept {
498     if (this->ptr) {
499       dealloc(this->ptr);
500     }
501   }
502   T *ptr;
503 };
504 
505 template <typename T>
Box(Box && other)506 Box<T>::Box(Box &&other) noexcept : ptr(other.ptr) {
507   other.ptr = nullptr;
508 }
509 
510 template <typename T>
Box(const T & val)511 Box<T>::Box(const T &val) {
512   allocation alloc;
513   ::new (alloc.ptr) T(val);
514   this->ptr = alloc.ptr;
515   alloc.ptr = nullptr;
516 }
517 
518 template <typename T>
Box(T && val)519 Box<T>::Box(T &&val) {
520   allocation alloc;
521   ::new (alloc.ptr) T(std::move(val));
522   this->ptr = alloc.ptr;
523   alloc.ptr = nullptr;
524 }
525 
526 template <typename T>
~Box()527 Box<T>::~Box() noexcept {
528   if (this->ptr) {
529     this->drop();
530   }
531 }
532 
533 template <typename T>
operator =(Box && other)534 Box<T> &Box<T>::operator=(Box &&other) &noexcept {
535   if (this->ptr) {
536     this->drop();
537   }
538   this->ptr = other.ptr;
539   other.ptr = nullptr;
540   return *this;
541 }
542 
543 template <typename T>
operator ->() const544 const T *Box<T>::operator->() const noexcept {
545   return this->ptr;
546 }
547 
548 template <typename T>
operator *() const549 const T &Box<T>::operator*() const noexcept {
550   return *this->ptr;
551 }
552 
553 template <typename T>
operator ->()554 T *Box<T>::operator->() noexcept {
555   return this->ptr;
556 }
557 
558 template <typename T>
operator *()559 T &Box<T>::operator*() noexcept {
560   return *this->ptr;
561 }
562 
563 template <typename T>
564 template <typename... Fields>
in_place(Fields &&...fields)565 Box<T> Box<T>::in_place(Fields &&...fields) {
566   allocation alloc;
567   auto ptr = alloc.ptr;
568   ::new (ptr) T{std::forward<Fields>(fields)...};
569   alloc.ptr = nullptr;
570   return from_raw(ptr);
571 }
572 
573 template <typename T>
swap(Box & rhs)574 void Box<T>::swap(Box &rhs) noexcept {
575   using std::swap;
576   swap(this->ptr, rhs.ptr);
577 }
578 
579 template <typename T>
from_raw(T * raw)580 Box<T> Box<T>::from_raw(T *raw) noexcept {
581   Box box = uninit{};
582   box.ptr = raw;
583   return box;
584 }
585 
586 template <typename T>
into_raw()587 T *Box<T>::into_raw() noexcept {
588   T *raw = this->ptr;
589   this->ptr = nullptr;
590   return raw;
591 }
592 
593 template <typename T>
Box(uninit)594 Box<T>::Box(uninit) noexcept {}
595 #endif // CXXBRIDGE1_RUST_BOX
596 
597 #ifndef CXXBRIDGE1_RUST_OPAQUE
598 #define CXXBRIDGE1_RUST_OPAQUE
599 class Opaque {
600 public:
601   Opaque() = delete;
602   Opaque(const Opaque &) = delete;
603   ~Opaque() = delete;
604 };
605 #endif // CXXBRIDGE1_RUST_OPAQUE
606 
607 #ifndef CXXBRIDGE1_IS_COMPLETE
608 #define CXXBRIDGE1_IS_COMPLETE
609 namespace detail {
610 namespace {
611 template <typename T, typename = std::size_t>
612 struct is_complete : std::false_type {};
613 template <typename T>
614 struct is_complete<T, decltype(sizeof(T))> : std::true_type {};
615 } // namespace
616 } // namespace detail
617 #endif // CXXBRIDGE1_IS_COMPLETE
618 
619 #ifndef CXXBRIDGE1_LAYOUT
620 #define CXXBRIDGE1_LAYOUT
621 class layout {
622   template <typename T>
623   friend std::size_t size_of();
624   template <typename T>
625   friend std::size_t align_of();
626   template <typename T>
627   static typename std::enable_if<std::is_base_of<Opaque, T>::value,
628                                  std::size_t>::type
do_size_of()629   do_size_of() {
630     return T::layout::size();
631   }
632   template <typename T>
633   static typename std::enable_if<!std::is_base_of<Opaque, T>::value,
634                                  std::size_t>::type
do_size_of()635   do_size_of() {
636     return sizeof(T);
637   }
638   template <typename T>
639   static
640       typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type
size_of()641       size_of() {
642     return do_size_of<T>();
643   }
644   template <typename T>
645   static typename std::enable_if<std::is_base_of<Opaque, T>::value,
646                                  std::size_t>::type
do_align_of()647   do_align_of() {
648     return T::layout::align();
649   }
650   template <typename T>
651   static typename std::enable_if<!std::is_base_of<Opaque, T>::value,
652                                  std::size_t>::type
do_align_of()653   do_align_of() {
654     return alignof(T);
655   }
656   template <typename T>
657   static
658       typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type
align_of()659       align_of() {
660     return do_align_of<T>();
661   }
662 };
663 
664 template <typename T>
size_of()665 std::size_t size_of() {
666   return layout::size_of<T>();
667 }
668 
669 template <typename T>
align_of()670 std::size_t align_of() {
671   return layout::align_of<T>();
672 }
673 #endif // CXXBRIDGE1_LAYOUT
674 
675 namespace detail {
676 template <typename T, typename = void *>
677 struct operator_new {
operator ()rust::cxxbridge1::detail::operator_new678   void *operator()(::std::size_t sz) { return ::operator new(sz); }
679 };
680 
681 template <typename T>
682 struct operator_new<T, decltype(T::operator new(sizeof(T)))> {
operator ()rust::cxxbridge1::detail::operator_new683   void *operator()(::std::size_t sz) { return T::operator new(sz); }
684 };
685 } // namespace detail
686 
687 template <typename T>
688 union ManuallyDrop {
689   T value;
ManuallyDrop(T && value)690   ManuallyDrop(T &&value) : value(::std::move(value)) {}
~ManuallyDrop()691   ~ManuallyDrop() {}
692 };
693 
694 template <typename T>
695 union MaybeUninit {
696   T value;
operator new(::std::size_t sz)697   void *operator new(::std::size_t sz) { return detail::operator_new<T>{}(sz); }
MaybeUninit()698   MaybeUninit() {}
~MaybeUninit()699   ~MaybeUninit() {}
700 };
701 } // namespace cxxbridge1
702 } // namespace rust
703 
704 namespace android {
705   namespace input {
706     struct RustPointerProperties;
707     struct RustInputDeviceIdentifier;
708     namespace verifier {
709       struct InputVerifier;
710     }
711     namespace keyboardClassifier {
712       struct KeyboardClassifier;
713     }
714   }
715 }
716 
717 namespace android {
718 namespace input {
719 namespace verifier {
720 #ifndef CXXBRIDGE1_STRUCT_android$input$verifier$InputVerifier
721 #define CXXBRIDGE1_STRUCT_android$input$verifier$InputVerifier
722 // Used to validate the incoming motion stream.
723 // This class is not thread-safe.
724 // State is stored in the "InputVerifier" object
725 // that can be created via the 'create' method.
726 // Usage:
727 //
728 // ```ignore
729 // Box<InputVerifier> verifier = create("inputChannel name");
730 // result = process_movement(verifier, ...);
731 // if (result) {
732 //    crash(result.error_message());
733 // }
734 // ```
735 struct InputVerifier final : public ::rust::Opaque {
736   ~InputVerifier() = delete;
737 
738 private:
739   friend ::rust::layout;
740   struct layout {
741     static ::std::size_t size() noexcept;
742     static ::std::size_t align() noexcept;
743   };
744 };
745 #endif // CXXBRIDGE1_STRUCT_android$input$verifier$InputVerifier
746 } // namespace verifier
747 
748 namespace keyboardClassifier {
749 #ifndef CXXBRIDGE1_STRUCT_android$input$keyboardClassifier$KeyboardClassifier
750 #define CXXBRIDGE1_STRUCT_android$input$keyboardClassifier$KeyboardClassifier
751 // Used to classify a keyboard into alphabetic and non-alphabetic
752 struct KeyboardClassifier final : public ::rust::Opaque {
753   ~KeyboardClassifier() = delete;
754 
755 private:
756   friend ::rust::layout;
757   struct layout {
758     static ::std::size_t size() noexcept;
759     static ::std::size_t align() noexcept;
760   };
761 };
762 #endif // CXXBRIDGE1_STRUCT_android$input$keyboardClassifier$KeyboardClassifier
763 } // namespace keyboardClassifier
764 
765 #ifndef CXXBRIDGE1_STRUCT_android$input$RustPointerProperties
766 #define CXXBRIDGE1_STRUCT_android$input$RustPointerProperties
767 struct RustPointerProperties final {
768   ::std::int32_t id;
769 
770   bool operator==(RustPointerProperties const &) const noexcept;
771   bool operator!=(RustPointerProperties const &) const noexcept;
772   using IsRelocatable = ::std::true_type;
773 };
774 #endif // CXXBRIDGE1_STRUCT_android$input$RustPointerProperties
775 
776 #ifndef CXXBRIDGE1_STRUCT_android$input$RustInputDeviceIdentifier
777 #define CXXBRIDGE1_STRUCT_android$input$RustInputDeviceIdentifier
778 struct RustInputDeviceIdentifier final {
779   ::rust::String name;
780   ::rust::String location;
781   ::rust::String unique_id;
782   ::std::uint16_t bus;
783   ::std::uint16_t vendor;
784   ::std::uint16_t product;
785   ::std::uint16_t version;
786   ::rust::String descriptor;
787 
788   using IsRelocatable = ::std::true_type;
789 };
790 #endif // CXXBRIDGE1_STRUCT_android$input$RustInputDeviceIdentifier
791 } // namespace input
792 
793 extern "C" {
android$cxxbridge1$shouldLog(::rust::Str tag)794 bool android$cxxbridge1$shouldLog(::rust::Str tag) noexcept {
795   bool (*shouldLog$)(::rust::Str) = ::android::shouldLog;
796   return shouldLog$(tag);
797 }
798 } // extern "C"
799 
800 namespace input {
801 namespace verifier {
802 extern "C" {
803 ::std::size_t android$input$verifier$cxxbridge1$InputVerifier$operator$sizeof() noexcept;
804 ::std::size_t android$input$verifier$cxxbridge1$InputVerifier$operator$alignof() noexcept;
805 
806 ::android::input::verifier::InputVerifier *android$input$verifier$cxxbridge1$create_input_verifier(::rust::String *name) noexcept;
807 
808 void android$input$verifier$cxxbridge1$process_movement(::android::input::verifier::InputVerifier &verifier, ::std::int32_t device_id, ::std::uint32_t source, ::std::uint32_t action, ::rust::Slice<::android::input::RustPointerProperties const> pointer_properties, ::std::uint32_t flags, ::rust::String *return$) noexcept;
809 
810 void android$input$verifier$cxxbridge1$reset_device(::android::input::verifier::InputVerifier &verifier, ::std::int32_t device_id) noexcept;
811 } // extern "C"
812 } // namespace verifier
813 
814 namespace keyboardClassifier {
815 extern "C" {
816 ::std::size_t android$input$keyboardClassifier$cxxbridge1$KeyboardClassifier$operator$sizeof() noexcept;
817 ::std::size_t android$input$keyboardClassifier$cxxbridge1$KeyboardClassifier$operator$alignof() noexcept;
818 
819 ::android::input::keyboardClassifier::KeyboardClassifier *android$input$keyboardClassifier$cxxbridge1$create_keyboard_classifier() noexcept;
820 
821 void android$input$keyboardClassifier$cxxbridge1$notify_keyboard_changed(::android::input::keyboardClassifier::KeyboardClassifier &classifier, ::std::int32_t device_id, ::android::input::RustInputDeviceIdentifier *identifier, ::std::uint32_t device_classes) noexcept;
822 
823 ::std::uint32_t android$input$keyboardClassifier$cxxbridge1$get_keyboard_type(::android::input::keyboardClassifier::KeyboardClassifier &classifier, ::std::int32_t device_id) noexcept;
824 
825 bool android$input$keyboardClassifier$cxxbridge1$is_finalized(::android::input::keyboardClassifier::KeyboardClassifier &classifier, ::std::int32_t device_id) noexcept;
826 
827 void android$input$keyboardClassifier$cxxbridge1$process_key(::android::input::keyboardClassifier::KeyboardClassifier &classifier, ::std::int32_t device_id, ::std::int32_t evdev_code, ::std::uint32_t modifier_state) noexcept;
828 } // extern "C"
829 } // namespace keyboardClassifier
830 
831 extern "C" {
832 bool android$input$cxxbridge1$RustPointerProperties$operator$eq(RustPointerProperties const &, RustPointerProperties const &) noexcept;
833 ::std::size_t android$input$cxxbridge1$RustPointerProperties$operator$hash(RustPointerProperties const &) noexcept;
834 } // extern "C"
835 } // namespace input
836 } // namespace android
837 
838 namespace std {
839 template <> struct hash<::android::input::RustPointerProperties> {
operator ()std::hash840   ::std::size_t operator()(::android::input::RustPointerProperties const &self) const noexcept {
841     return ::android::input::android$input$cxxbridge1$RustPointerProperties$operator$hash(self);
842   }
843 };
844 } // namespace std
845 
846 namespace android {
847 namespace input {
848 namespace verifier {
size()849 ::std::size_t InputVerifier::layout::size() noexcept {
850   return android$input$verifier$cxxbridge1$InputVerifier$operator$sizeof();
851 }
852 
align()853 ::std::size_t InputVerifier::layout::align() noexcept {
854   return android$input$verifier$cxxbridge1$InputVerifier$operator$alignof();
855 }
856 
create(::rust::String name)857 ::rust::Box<::android::input::verifier::InputVerifier> create(::rust::String name) noexcept {
858   return ::rust::Box<::android::input::verifier::InputVerifier>::from_raw(android$input$verifier$cxxbridge1$create_input_verifier(&name));
859 }
860 
process_movement(::android::input::verifier::InputVerifier & verifier,::std::int32_t device_id,::std::uint32_t source,::std::uint32_t action,::rust::Slice<::android::input::RustPointerProperties const> pointer_properties,::std::uint32_t flags)861 ::rust::String process_movement(::android::input::verifier::InputVerifier &verifier, ::std::int32_t device_id, ::std::uint32_t source, ::std::uint32_t action, ::rust::Slice<::android::input::RustPointerProperties const> pointer_properties, ::std::uint32_t flags) noexcept {
862   ::rust::MaybeUninit<::rust::String> return$;
863   android$input$verifier$cxxbridge1$process_movement(verifier, device_id, source, action, pointer_properties, flags, &return$.value);
864   return ::std::move(return$.value);
865 }
866 
reset_device(::android::input::verifier::InputVerifier & verifier,::std::int32_t device_id)867 void reset_device(::android::input::verifier::InputVerifier &verifier, ::std::int32_t device_id) noexcept {
868   android$input$verifier$cxxbridge1$reset_device(verifier, device_id);
869 }
870 } // namespace verifier
871 
872 namespace keyboardClassifier {
size()873 ::std::size_t KeyboardClassifier::layout::size() noexcept {
874   return android$input$keyboardClassifier$cxxbridge1$KeyboardClassifier$operator$sizeof();
875 }
876 
align()877 ::std::size_t KeyboardClassifier::layout::align() noexcept {
878   return android$input$keyboardClassifier$cxxbridge1$KeyboardClassifier$operator$alignof();
879 }
880 
create()881 ::rust::Box<::android::input::keyboardClassifier::KeyboardClassifier> create() noexcept {
882   return ::rust::Box<::android::input::keyboardClassifier::KeyboardClassifier>::from_raw(android$input$keyboardClassifier$cxxbridge1$create_keyboard_classifier());
883 }
884 
notifyKeyboardChanged(::android::input::keyboardClassifier::KeyboardClassifier & classifier,::std::int32_t device_id,::android::input::RustInputDeviceIdentifier identifier,::std::uint32_t device_classes)885 void notifyKeyboardChanged(::android::input::keyboardClassifier::KeyboardClassifier &classifier, ::std::int32_t device_id, ::android::input::RustInputDeviceIdentifier identifier, ::std::uint32_t device_classes) noexcept {
886   ::rust::ManuallyDrop<::android::input::RustInputDeviceIdentifier> identifier$(::std::move(identifier));
887   android$input$keyboardClassifier$cxxbridge1$notify_keyboard_changed(classifier, device_id, &identifier$.value, device_classes);
888 }
889 
getKeyboardType(::android::input::keyboardClassifier::KeyboardClassifier & classifier,::std::int32_t device_id)890 ::std::uint32_t getKeyboardType(::android::input::keyboardClassifier::KeyboardClassifier &classifier, ::std::int32_t device_id) noexcept {
891   return android$input$keyboardClassifier$cxxbridge1$get_keyboard_type(classifier, device_id);
892 }
893 
isFinalized(::android::input::keyboardClassifier::KeyboardClassifier & classifier,::std::int32_t device_id)894 bool isFinalized(::android::input::keyboardClassifier::KeyboardClassifier &classifier, ::std::int32_t device_id) noexcept {
895   return android$input$keyboardClassifier$cxxbridge1$is_finalized(classifier, device_id);
896 }
897 
processKey(::android::input::keyboardClassifier::KeyboardClassifier & classifier,::std::int32_t device_id,::std::int32_t evdev_code,::std::uint32_t modifier_state)898 void processKey(::android::input::keyboardClassifier::KeyboardClassifier &classifier, ::std::int32_t device_id, ::std::int32_t evdev_code, ::std::uint32_t modifier_state) noexcept {
899   android$input$keyboardClassifier$cxxbridge1$process_key(classifier, device_id, evdev_code, modifier_state);
900 }
901 } // namespace keyboardClassifier
902 
operator ==(RustPointerProperties const & rhs) const903 bool RustPointerProperties::operator==(RustPointerProperties const &rhs) const noexcept {
904   return android$input$cxxbridge1$RustPointerProperties$operator$eq(*this, rhs);
905 }
906 
operator !=(RustPointerProperties const & rhs) const907 bool RustPointerProperties::operator!=(RustPointerProperties const &rhs) const noexcept {
908   return !(*this == rhs);
909 }
910 } // namespace input
911 } // namespace android
912 
913 extern "C" {
914 ::android::input::verifier::InputVerifier *cxxbridge1$box$android$input$verifier$InputVerifier$alloc() noexcept;
915 void cxxbridge1$box$android$input$verifier$InputVerifier$dealloc(::android::input::verifier::InputVerifier *) noexcept;
916 void cxxbridge1$box$android$input$verifier$InputVerifier$drop(::rust::Box<::android::input::verifier::InputVerifier> *ptr) noexcept;
917 
918 ::android::input::keyboardClassifier::KeyboardClassifier *cxxbridge1$box$android$input$keyboardClassifier$KeyboardClassifier$alloc() noexcept;
919 void cxxbridge1$box$android$input$keyboardClassifier$KeyboardClassifier$dealloc(::android::input::keyboardClassifier::KeyboardClassifier *) noexcept;
920 void cxxbridge1$box$android$input$keyboardClassifier$KeyboardClassifier$drop(::rust::Box<::android::input::keyboardClassifier::KeyboardClassifier> *ptr) noexcept;
921 } // extern "C"
922 
923 namespace rust {
924 inline namespace cxxbridge1 {
925 template <>
alloc()926 ::android::input::verifier::InputVerifier *Box<::android::input::verifier::InputVerifier>::allocation::alloc() noexcept {
927   return cxxbridge1$box$android$input$verifier$InputVerifier$alloc();
928 }
929 template <>
dealloc(::android::input::verifier::InputVerifier * ptr)930 void Box<::android::input::verifier::InputVerifier>::allocation::dealloc(::android::input::verifier::InputVerifier *ptr) noexcept {
931   cxxbridge1$box$android$input$verifier$InputVerifier$dealloc(ptr);
932 }
933 template <>
drop()934 void Box<::android::input::verifier::InputVerifier>::drop() noexcept {
935   cxxbridge1$box$android$input$verifier$InputVerifier$drop(this);
936 }
937 template <>
alloc()938 ::android::input::keyboardClassifier::KeyboardClassifier *Box<::android::input::keyboardClassifier::KeyboardClassifier>::allocation::alloc() noexcept {
939   return cxxbridge1$box$android$input$keyboardClassifier$KeyboardClassifier$alloc();
940 }
941 template <>
dealloc(::android::input::keyboardClassifier::KeyboardClassifier * ptr)942 void Box<::android::input::keyboardClassifier::KeyboardClassifier>::allocation::dealloc(::android::input::keyboardClassifier::KeyboardClassifier *ptr) noexcept {
943   cxxbridge1$box$android$input$keyboardClassifier$KeyboardClassifier$dealloc(ptr);
944 }
945 template <>
drop()946 void Box<::android::input::keyboardClassifier::KeyboardClassifier>::drop() noexcept {
947   cxxbridge1$box$android$input$keyboardClassifier$KeyboardClassifier$drop(this);
948 }
949 } // namespace cxxbridge1
950 } // namespace rust
951