| David Tolnay | 97c7210 | 2020-01-25 16:49:00 -0800 | [diff] [blame] | 1 | #pragma once |
| David Tolnay | 736cbca | 2020-03-11 16:49:18 -0700 | [diff] [blame] | 2 | #include "rust/cxx.h" |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame] | 3 | #include <memory> |
| 4 | #include <string> |
| David Tolnay | 97c7210 | 2020-01-25 16:49:00 -0800 | [diff] [blame] | 5 | |
| 6 | namespace tests { |
| 7 | |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame] | 8 | struct R; |
| 9 | struct Shared; |
| 10 | |
| 11 | class C { |
| 12 | public: |
| 13 | C(size_t n); |
| David Tolnay | 3fd7f56 | 2020-01-26 17:47:11 -0800 | [diff] [blame] | 14 | size_t get() const; |
| Joel Galenson | 3d4f612 | 2020-04-07 15:54:05 -0700 | [diff] [blame] | 15 | size_t set(size_t n); |
| Joel Galenson | e1e969d | 2020-04-21 12:50:20 -0700 | [diff] [blame] | 16 | size_t get2() const; |
| 17 | size_t set2(size_t n); |
| David Tolnay | de5340e | 2020-04-25 14:03:21 -0700 | [diff] [blame] | 18 | const std::vector<uint8_t> &get_v() const; |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame] | 19 | |
| 20 | private: |
| 21 | size_t n; |
| David Tolnay | de5340e | 2020-04-25 14:03:21 -0700 | [diff] [blame] | 22 | std::vector<uint8_t> v; |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | size_t c_return_primitive(); |
| 26 | Shared c_return_shared(); |
| David Tolnay | 750755e | 2020-03-01 13:04:08 -0800 | [diff] [blame] | 27 | rust::Box<R> c_return_box(); |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame] | 28 | std::unique_ptr<C> c_return_unique_ptr(); |
| 29 | const size_t &c_return_ref(const Shared &shared); |
| David Tolnay | 750755e | 2020-03-01 13:04:08 -0800 | [diff] [blame] | 30 | rust::Str c_return_str(const Shared &shared); |
| Adrian Taylor | f5dd552 | 2020-04-13 16:50:14 -0700 | [diff] [blame] | 31 | rust::Slice<uint8_t> c_return_sliceu8(const Shared &shared); |
| David Tolnay | 750755e | 2020-03-01 13:04:08 -0800 | [diff] [blame] | 32 | rust::String c_return_rust_string(); |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame] | 33 | std::unique_ptr<std::string> c_return_unique_ptr_string(); |
| Myron Ahn | eba35cf | 2020-02-05 19:41:51 +0700 | [diff] [blame] | 34 | std::unique_ptr<std::vector<uint8_t>> c_return_unique_ptr_vector_u8(); |
| 35 | std::unique_ptr<std::vector<double>> c_return_unique_ptr_vector_f64(); |
| 36 | std::unique_ptr<std::vector<Shared>> c_return_unique_ptr_vector_shared(); |
| David Tolnay | 1bcc9fe | 2020-04-25 13:51:07 -0700 | [diff] [blame] | 37 | std::unique_ptr<std::vector<C>> c_return_unique_ptr_vector_opaque(); |
| David Tolnay | de5340e | 2020-04-25 14:03:21 -0700 | [diff] [blame] | 38 | const std::vector<uint8_t> &c_return_ref_vector(const C &c); |
| David Tolnay | b41e74c | 2020-04-25 15:06:18 -0700 | [diff] [blame] | 39 | rust::Vec<uint8_t> c_return_rust_vec(); |
| David Tolnay | 7798969 | 2020-04-25 15:57:47 -0700 | [diff] [blame] | 40 | const rust::Vec<uint8_t> &c_return_ref_rust_vec(const C &c); |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame] | 41 | |
| 42 | void c_take_primitive(size_t n); |
| 43 | void c_take_shared(Shared shared); |
| David Tolnay | 750755e | 2020-03-01 13:04:08 -0800 | [diff] [blame] | 44 | void c_take_box(rust::Box<R> r); |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame] | 45 | void c_take_unique_ptr(std::unique_ptr<C> c); |
| 46 | void c_take_ref_r(const R &r); |
| 47 | void c_take_ref_c(const C &c); |
| David Tolnay | 750755e | 2020-03-01 13:04:08 -0800 | [diff] [blame] | 48 | void c_take_str(rust::Str s); |
| Adrian Taylor | f5dd552 | 2020-04-13 16:50:14 -0700 | [diff] [blame] | 49 | void c_take_sliceu8(rust::Slice<uint8_t> s); |
| David Tolnay | 750755e | 2020-03-01 13:04:08 -0800 | [diff] [blame] | 50 | void c_take_rust_string(rust::String s); |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame] | 51 | void c_take_unique_ptr_string(std::unique_ptr<std::string> s); |
| Myron Ahn | eba35cf | 2020-02-05 19:41:51 +0700 | [diff] [blame] | 52 | void c_take_unique_ptr_vector_u8(std::unique_ptr<std::vector<uint8_t>> v); |
| 53 | void c_take_unique_ptr_vector_f64(std::unique_ptr<std::vector<double>> v); |
| 54 | void c_take_unique_ptr_vector_shared(std::unique_ptr<std::vector<Shared>> v); |
| David Tolnay | 2244d1f | 2020-04-25 13:58:18 -0700 | [diff] [blame] | 55 | void c_take_ref_vector(const std::vector<uint8_t> &v); |
| David Tolnay | d2ce8a9 | 2020-04-25 16:16:45 -0700 | [diff] [blame^] | 56 | void c_take_rust_vec(rust::Vec<uint8_t> v); |
| 57 | void c_take_rust_vec_shared(rust::Vec<Shared> v); |
| 58 | void c_take_ref_rust_vec(const rust::Vec<uint8_t> &v); |
| David Tolnay | 75dca2e | 2020-03-25 20:17:52 -0700 | [diff] [blame] | 59 | void c_take_callback(rust::Fn<size_t(rust::String)> callback); |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame] | 60 | |
| David Tolnay | ebef4a2 | 2020-03-17 15:33:47 -0700 | [diff] [blame] | 61 | void c_try_return_void(); |
| 62 | size_t c_try_return_primitive(); |
| 63 | size_t c_fail_return_primitive(); |
| David Tolnay | 9964262 | 2020-03-25 13:07:35 -0700 | [diff] [blame] | 64 | rust::Box<R> c_try_return_box(); |
| 65 | const rust::String &c_try_return_ref(const rust::String &); |
| 66 | rust::Str c_try_return_str(rust::Str); |
| Adrian Taylor | f5dd552 | 2020-04-13 16:50:14 -0700 | [diff] [blame] | 67 | rust::Slice<uint8_t> c_try_return_sliceu8(rust::Slice<uint8_t>); |
| David Tolnay | 9964262 | 2020-03-25 13:07:35 -0700 | [diff] [blame] | 68 | rust::String c_try_return_rust_string(); |
| 69 | std::unique_ptr<std::string> c_try_return_unique_ptr_string(); |
| David Tolnay | 8b9d176 | 2020-04-25 16:05:46 -0700 | [diff] [blame] | 70 | rust::Vec<uint8_t> c_try_return_rust_vec(); |
| David Tolnay | 7798969 | 2020-04-25 15:57:47 -0700 | [diff] [blame] | 71 | const rust::Vec<uint8_t> &c_try_return_ref_rust_vec(const C &c); |
| David Tolnay | ebef4a2 | 2020-03-17 15:33:47 -0700 | [diff] [blame] | 72 | |
| David Tolnay | 97c7210 | 2020-01-25 16:49:00 -0800 | [diff] [blame] | 73 | } // namespace tests |