File tree Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ pub mod ffi2 {
25
25
#[ namespace ( namespace = G ) ]
26
26
type G = crate :: other:: G ;
27
27
28
+ #[ namespace( namespace = H ) ]
29
+ type H ;
30
+
28
31
fn c_take_trivial_ptr ( d : UniquePtr < D > ) ;
29
32
fn c_take_trivial_ref ( d : & D ) ;
30
33
fn c_take_trivial ( d : D ) ;
@@ -41,5 +44,7 @@ pub mod ffi2 {
41
44
fn c_return_trivial_ns ( ) -> G ;
42
45
fn c_return_opaque_ptr ( ) -> UniquePtr < E > ;
43
46
fn c_return_ns_opaque_ptr ( ) -> UniquePtr < F > ;
47
+ fn c_return_ns_unique_ptr ( ) -> UniquePtr < H > ;
48
+ fn c_take_ref_ns_c ( h : & H ) ;
44
49
}
45
50
}
Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ std::unique_ptr<C> c_return_unique_ptr() {
55
55
return std::unique_ptr<C>(new C{2020 });
56
56
}
57
57
58
+ std::unique_ptr<::H::H> c_return_ns_unique_ptr () {
59
+ return std::unique_ptr<::H::H>(new ::H::H{" hello" });
60
+ }
61
+
58
62
const size_t &c_return_ref (const Shared &shared) { return shared.z ; }
59
63
60
64
const size_t &c_return_ns_ref (const ::A::AShared &shared) { return shared.z ; }
@@ -220,6 +224,12 @@ void c_take_ref_c(const C &c) {
220
224
}
221
225
}
222
226
227
+ void c_take_ref_ns_c (const ::H::H &h) {
228
+ if (h.h == " hello" ) {
229
+ cxx_test_suite_set_correct ();
230
+ }
231
+ }
232
+
223
233
void c_take_str (rust::Str s) {
224
234
if (std::string (s) == " 2020" ) {
225
235
cxx_test_suite_set_correct ();
Original file line number Diff line number Diff line change @@ -25,6 +25,13 @@ namespace G {
25
25
};
26
26
}
27
27
28
+ namespace H {
29
+ class H {
30
+ public:
31
+ std::string h;
32
+ };
33
+ }
34
+
28
35
namespace tests {
29
36
30
37
struct R ;
@@ -70,6 +77,7 @@ ::A::AShared c_return_ns_shared();
70
77
::A::B::ABShared c_return_nested_ns_shared ();
71
78
rust::Box<R> c_return_box ();
72
79
std::unique_ptr<C> c_return_unique_ptr ();
80
+ std::unique_ptr<::H::H> c_return_ns_unique_ptr ();
73
81
const size_t &c_return_ref (const Shared &shared);
74
82
const size_t &c_return_ns_ref (const ::A::AShared &shared);
75
83
const size_t &c_return_nested_ns_ref (const ::A::B::ABShared &shared);
@@ -103,6 +111,7 @@ void c_take_box(rust::Box<R> r);
103
111
void c_take_unique_ptr (std::unique_ptr<C> c);
104
112
void c_take_ref_r (const R &r);
105
113
void c_take_ref_c (const C &c);
114
+ void c_take_ref_ns_c (const ::H::H &h);
106
115
void c_take_str (rust::Str s);
107
116
void c_take_sliceu8 (rust::Slice<uint8_t > s);
108
117
void c_take_rust_string (rust::String s);
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ fn test_c_return() {
30
30
assert_eq ! ( 2020 , ffi:: c_return_shared( ) . z) ;
31
31
assert_eq ! ( 2020 , * ffi:: c_return_box( ) ) ;
32
32
ffi:: c_return_unique_ptr ( ) ;
33
+ ffi2:: c_return_ns_unique_ptr ( ) ;
33
34
assert_eq ! ( 2020 , * ffi:: c_return_ref( & shared) ) ;
34
35
assert_eq ! ( 2020 , * ffi:: c_return_ns_ref( & ns_shared) ) ;
35
36
assert_eq ! ( 2020 , * ffi:: c_return_nested_ns_ref( & nested_ns_shared) ) ;
@@ -97,13 +98,15 @@ fn test_c_try_return() {
97
98
#[ test]
98
99
fn test_c_take ( ) {
99
100
let unique_ptr = ffi:: c_return_unique_ptr ( ) ;
101
+ let unique_ptr_ns = ffi2:: c_return_ns_unique_ptr ( ) ;
100
102
101
103
check ! ( ffi:: c_take_primitive( 2020 ) ) ;
102
104
check ! ( ffi:: c_take_shared( ffi:: Shared { z: 2020 } ) ) ;
103
105
check ! ( ffi:: c_take_ns_shared( ffi:: AShared { z: 2020 } ) ) ;
104
106
check ! ( ffi:: c_take_nested_ns_shared( ffi:: ABShared { z: 2020 } ) ) ;
105
107
check ! ( ffi:: c_take_box( Box :: new( 2020 ) ) ) ;
106
108
check ! ( ffi:: c_take_ref_c( & unique_ptr) ) ;
109
+ check ! ( ffi2:: c_take_ref_ns_c( & unique_ptr_ns) ) ;
107
110
check ! ( cxx_test_suite:: module:: ffi:: c_take_unique_ptr( unique_ptr) ) ;
108
111
check ! ( ffi:: c_take_str( "2020" ) ) ;
109
112
check ! ( ffi:: c_take_sliceu8( b"2020" ) ) ;
You can’t perform that action at this time.
0 commit comments