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