Lines Matching refs:out
3 use crate::gen::out::{Content, OutFile};
43 pub(super) fn write(out: &mut OutFile) { in write()
44 if out.builtin == Default::default() { in write()
48 let include = &mut out.include; in write()
49 let builtin = &mut out.builtin; in write()
50 let out = &mut builtin.content; in write() localVariable
134 out.begin_block(Block::Namespace("rust")); in write()
135 out.begin_block(Block::InlineNamespace("cxxbridge1")); in write()
139 writeln!(out, "// #include \"rust/cxx.h\""); in write()
141 ifndef::write(out, builtin.panic, "CXXBRIDGE1_PANIC"); in write()
144 out.next_section(); in write()
145 writeln!(out, "struct unsafe_bitcopy_t;"); in write()
149 out.begin_block(Block::AnonymousNamespace); in write()
150 writeln!(out, "template <typename T>"); in write()
151 writeln!(out, "class impl;"); in write()
152 out.end_block(Block::AnonymousNamespace); in write()
155 out.next_section(); in write()
157 writeln!(out, "class String;"); in write()
160 writeln!(out, "class Opaque;"); in write()
164 out.next_section(); in write()
165 writeln!(out, "template <typename T>"); in write()
166 writeln!(out, "::std::size_t size_of();"); in write()
167 writeln!(out, "template <typename T>"); in write()
168 writeln!(out, "::std::size_t align_of();"); in write()
171 ifndef::write(out, builtin.rust_string, "CXXBRIDGE1_RUST_STRING"); in write()
172 ifndef::write(out, builtin.rust_str, "CXXBRIDGE1_RUST_STR"); in write()
173 ifndef::write(out, builtin.rust_slice, "CXXBRIDGE1_RUST_SLICE"); in write()
174 ifndef::write(out, builtin.rust_box, "CXXBRIDGE1_RUST_BOX"); in write()
175 ifndef::write(out, builtin.unsafe_bitcopy_t, "CXXBRIDGE1_RUST_BITCOPY_T"); in write()
176 ifndef::write(out, builtin.unsafe_bitcopy, "CXXBRIDGE1_RUST_BITCOPY"); in write()
177 ifndef::write(out, builtin.rust_vec, "CXXBRIDGE1_RUST_VEC"); in write()
178 ifndef::write(out, builtin.rust_fn, "CXXBRIDGE1_RUST_FN"); in write()
179 ifndef::write(out, builtin.rust_error, "CXXBRIDGE1_RUST_ERROR"); in write()
180 ifndef::write(out, builtin.rust_isize, "CXXBRIDGE1_RUST_ISIZE"); in write()
181 ifndef::write(out, builtin.opaque, "CXXBRIDGE1_RUST_OPAQUE"); in write()
182 ifndef::write(out, builtin.is_complete, "CXXBRIDGE1_IS_COMPLETE"); in write()
183 ifndef::write(out, builtin.layout, "CXXBRIDGE1_LAYOUT"); in write()
184 ifndef::write(out, builtin.relocatable, "CXXBRIDGE1_RELOCATABLE"); in write()
188 out.next_section(); in write()
189 writeln!(out, "class Str::uninit {{}};"); in write()
190 writeln!(out, "inline Str::Str(uninit) noexcept {{}}"); in write()
194 out.next_section(); in write()
195 writeln!(out, "template <typename T>"); in write()
196 writeln!(out, "class Slice<T>::uninit {{}};"); in write()
197 writeln!(out, "template <typename T>"); in write()
198 writeln!(out, "inline Slice<T>::Slice(uninit) noexcept {{}}"); in write()
201 out.begin_block(Block::Namespace("detail")); in write()
206 out.next_section(); in write()
207 writeln!(out, "template <typename T, typename = void *>"); in write()
208 writeln!(out, "struct operator_new {{"); in write()
210 out, in write()
213 writeln!(out, "}};"); in write()
214 out.next_section(); in write()
215 writeln!(out, "template <typename T>"); in write()
217 out, in write()
221 out, in write()
224 writeln!(out, "}};"); in write()
227 out.end_block(Block::Namespace("detail")); in write()
230 out.next_section(); in write()
232 writeln!(out, "template <typename T>"); in write()
233 writeln!(out, "union ManuallyDrop {{"); in write()
234 writeln!(out, " T value;"); in write()
236 out, in write()
239 writeln!(out, " ~ManuallyDrop() {{}}"); in write()
240 writeln!(out, "}};"); in write()
245 out.next_section(); in write()
246 writeln!(out, "template <typename T>"); in write()
247 writeln!(out, "union MaybeUninit {{"); in write()
248 writeln!(out, " T value;"); in write()
250 out, in write()
253 writeln!(out, " MaybeUninit() {{}}"); in write()
254 writeln!(out, " ~MaybeUninit() {{}}"); in write()
255 writeln!(out, "}};"); in write()
258 out.begin_block(Block::AnonymousNamespace); in write()
263 out.next_section(); in write()
264 out.begin_block(Block::Namespace("repr")); in write()
265 writeln!(out, "using Fat = ::std::array<::std::uintptr_t, 2>;"); in write()
266 out.end_block(Block::Namespace("repr")); in write()
271 out.next_section(); in write()
272 out.begin_block(Block::Namespace("repr")); in write()
273 writeln!(out, "struct PtrLen final {{"); in write()
274 writeln!(out, " void *ptr;"); in write()
275 writeln!(out, " ::std::size_t len;"); in write()
276 writeln!(out, "}};"); in write()
277 out.end_block(Block::Namespace("repr")); in write()
281 out.next_section(); in write()
282 writeln!(out, "template <>"); in write()
283 writeln!(out, "class impl<Str> final {{"); in write()
284 writeln!(out, "public:"); in write()
287 out, in write()
290 writeln!(out, " Str str = Str::uninit{{}};"); in write()
291 writeln!(out, " str.repr = repr;"); in write()
292 writeln!(out, " return str;"); in write()
293 writeln!(out, " }}"); in write()
296 writeln!(out, " static repr::Fat repr(Str str) noexcept {{"); in write()
297 writeln!(out, " return str.repr;"); in write()
298 writeln!(out, " }}"); in write()
300 writeln!(out, "}};"); in write()
304 out.next_section(); in write()
305 writeln!(out, "template <typename T>"); in write()
306 writeln!(out, "class impl<Slice<T>> final {{"); in write()
307 writeln!(out, "public:"); in write()
309 writeln!(out, " static Slice<T> slice(repr::Fat repr) noexcept {{"); in write()
310 writeln!(out, " Slice<T> slice = typename Slice<T>::uninit{{}};"); in write()
311 writeln!(out, " slice.repr = repr;"); in write()
312 writeln!(out, " return slice;"); in write()
313 writeln!(out, " }}"); in write()
316 writeln!(out, " static repr::Fat repr(Slice<T> slice) noexcept {{"); in write()
317 writeln!(out, " return slice.repr;"); in write()
318 writeln!(out, " }}"); in write()
320 writeln!(out, "}};"); in write()
324 out.next_section(); in write()
325 writeln!(out, "template <>"); in write()
326 writeln!(out, "class impl<Error> final {{"); in write()
327 writeln!(out, "public:"); in write()
328 writeln!(out, " static Error error(repr::PtrLen repr) noexcept {{"); in write()
329 writeln!(out, " Error error;"); in write()
330 writeln!(out, " error.msg = static_cast<const char *>(repr.ptr);"); in write()
331 writeln!(out, " error.len = repr.len;"); in write()
332 writeln!(out, " return error;"); in write()
333 writeln!(out, " }}"); in write()
334 writeln!(out, "}};"); in write()
338 out.next_section(); in write()
339 writeln!(out, "template <bool> struct deleter_if {{"); in write()
340 writeln!(out, " template <typename T> void operator()(T *) {{}}"); in write()
341 writeln!(out, "}};"); in write()
342 out.next_section(); in write()
343 writeln!(out, "template <> struct deleter_if<true> {{"); in write()
345 out, in write()
348 writeln!(out, "}};"); in write()
351 out.end_block(Block::AnonymousNamespace); in write()
352 out.end_block(Block::InlineNamespace("cxxbridge1")); in write()
355 out.begin_block(Block::Namespace("behavior")); in write()
359 writeln!(out, "class missing {{}};"); in write()
360 writeln!(out, "missing trycatch(...);"); in write()
361 writeln!(out); in write()
362 writeln!(out, "template <typename Try, typename Fail>"); in write()
363 writeln!(out, "static typename ::std::enable_if<"); in write()
365 out, in write()
368 writeln!(out, " missing>::value>::type"); in write()
369 writeln!(out, "trycatch(Try &&func, Fail &&fail) noexcept try {{"); in write()
370 writeln!(out, " func();"); in write()
371 writeln!(out, "}} catch (const ::std::exception &e) {{"); in write()
372 writeln!(out, " fail(e.what());"); in write()
373 writeln!(out, "}}"); in write()
374 out.end_block(Block::Namespace("behavior")); in write()
377 out.end_block(Block::Namespace("rust")); in write()
381 out.begin_block(Block::ExternC); in write()
383 out, in write()
386 out.end_block(Block::ExternC); in write()