| David Tolnay | 97c7210 | 2020-01-25 16:49:00 -0800 | [diff] [blame] | 1 | #include "tests/ffi/lib.rs" |
| 2 | #include "tests/ffi/tests.h" |
| 3 | |
| 4 | namespace tests { |
| 5 | |
| David Tolnay | ad5b8af | 2020-01-26 16:59:13 -0800 | [diff] [blame^] | 6 | C::C(size_t n) : n(n) {} |
| 7 | |
| 8 | size_t c_return_primitive() { |
| 9 | return 2020; |
| 10 | } |
| 11 | |
| 12 | Shared c_return_shared() { |
| 13 | return Shared{2020}; |
| 14 | } |
| 15 | |
| 16 | std::unique_ptr<C> c_return_unique_ptr() { |
| 17 | return std::unique_ptr<C>(new C{2020}); |
| 18 | } |
| 19 | |
| 20 | const size_t &c_return_ref(const Shared &shared) { |
| 21 | return shared.z; |
| 22 | } |
| 23 | |
| 24 | cxxbridge::RustStr c_return_str(const Shared &shared) { |
| 25 | (void)shared; |
| 26 | return "2020"; |
| 27 | } |
| 28 | |
| 29 | cxxbridge::RustString c_return_rust_string() { |
| 30 | return "2020"; |
| 31 | } |
| 32 | |
| 33 | std::unique_ptr<std::string> c_return_unique_ptr_string() { |
| 34 | return std::unique_ptr<std::string>(new std::string("2020")); |
| 35 | } |
| 36 | |
| 37 | void c_take_primitive(size_t n) { |
| 38 | (void)n; |
| 39 | } |
| 40 | |
| 41 | void c_take_shared(Shared shared) { |
| 42 | (void)shared; |
| 43 | } |
| 44 | |
| 45 | void c_take_box(cxxbridge::RustBox<R> r) { |
| 46 | (void)r; |
| 47 | } |
| 48 | |
| 49 | void c_take_unique_ptr(std::unique_ptr<C> c) { |
| 50 | (void)c; |
| 51 | } |
| 52 | |
| 53 | void c_take_ref_r(const R &r) { |
| 54 | (void)r; |
| 55 | } |
| 56 | |
| 57 | void c_take_ref_c(const C &c) { |
| 58 | (void)c; |
| 59 | } |
| 60 | |
| 61 | void c_take_str(cxxbridge::RustStr s) { |
| 62 | (void)s; |
| 63 | } |
| 64 | |
| 65 | void c_take_rust_string(cxxbridge::RustString s) { |
| 66 | (void)s; |
| 67 | } |
| 68 | |
| 69 | void c_take_unique_ptr_string(std::unique_ptr<std::string> s) { |
| 70 | (void)s; |
| 71 | } |
| 72 | |
| David Tolnay | 97c7210 | 2020-01-25 16:49:00 -0800 | [diff] [blame] | 73 | } // namespace tests |