File tree 3 files changed +21
-0
lines changed
3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,15 @@ pub mod ffi {
209
209
type Job = crate :: module:: ffi:: Job ;
210
210
}
211
211
212
+ unsafe extern "C++" {
213
+ type Borrow < ' a > ;
214
+
215
+ fn c_return_borrow < ' a > ( s : & ' a CxxString ) -> UniquePtr < Borrow < ' a > > ;
216
+
217
+ #[ rust_name = "c_return_borrow_elided" ]
218
+ fn c_return_borrow ( s : & CxxString ) -> UniquePtr < Borrow > ;
219
+ }
220
+
212
221
#[ repr( u32 ) ]
213
222
#[ derive( Hash ) ]
214
223
enum COwnedEnum {
Original file line number Diff line number Diff line change @@ -207,6 +207,12 @@ ::A::B::ABEnum c_return_nested_ns_enum(uint16_t n) {
207
207
}
208
208
}
209
209
210
+ Borrow::Borrow (const std::string &s) : s(s) {}
211
+
212
+ std::unique_ptr<Borrow> c_return_borrow (const std::string &s) {
213
+ return std::unique_ptr<Borrow>(new Borrow (s));
214
+ }
215
+
210
216
void c_take_primitive (size_t n) {
211
217
if (n == 2020 ) {
212
218
cxx_test_suite_set_correct ();
Original file line number Diff line number Diff line change @@ -77,6 +77,11 @@ enum COwnedEnum {
77
77
CVAL2,
78
78
};
79
79
80
+ struct Borrow {
81
+ Borrow (const std::string &s);
82
+ const std::string &s;
83
+ };
84
+
80
85
size_t c_return_primitive ();
81
86
Shared c_return_shared ();
82
87
::A::AShared c_return_ns_shared ();
@@ -110,6 +115,7 @@ size_t c_return_sum(size_t n1, size_t n2);
110
115
Enum c_return_enum (uint16_t n);
111
116
::A::AEnum c_return_ns_enum (uint16_t n);
112
117
::A::B::ABEnum c_return_nested_ns_enum (uint16_t n);
118
+ std::unique_ptr<Borrow> c_return_borrow (const std::string &s);
113
119
114
120
void c_take_primitive (size_t n);
115
121
void c_take_shared (Shared shared);
You can’t perform that action at this time.
0 commit comments