| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 1 | use crate::gen::block::Block; |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 2 | use crate::gen::ifndef; |
| 3 | use crate::gen::out::{Content, OutFile}; |
| David Tolnay | 8c14d9a | 2020-10-31 21:52:38 -0700 | [diff] [blame] | 4 | |
| David Tolnay | 3be0e1f | 2020-10-31 20:53:00 -0700 | [diff] [blame] | 5 | #[derive(Default, PartialEq)] |
| David Tolnay | 97c5b86 | 2020-11-01 14:59:01 -0800 | [diff] [blame] | 6 | pub struct Builtins<'a> { |
| David Tolnay | 3be0e1f | 2020-10-31 20:53:00 -0700 | [diff] [blame] | 7 | pub panic: bool, |
| 8 | pub rust_string: bool, |
| 9 | pub rust_str: bool, |
| 10 | pub rust_slice: bool, |
| 11 | pub rust_box: bool, |
| 12 | pub rust_vec: bool, |
| 13 | pub rust_fn: bool, |
| 14 | pub rust_isize: bool, |
| David Tolnay | 365fc7c | 2020-11-25 16:08:13 -0800 | [diff] [blame] | 15 | pub opaque: bool, |
| David Tolnay | 3be0e1f | 2020-10-31 20:53:00 -0700 | [diff] [blame] | 16 | pub unsafe_bitcopy: bool, |
| 17 | pub rust_error: bool, |
| 18 | pub manually_drop: bool, |
| 19 | pub maybe_uninit: bool, |
| 20 | pub trycatch: bool, |
| David Tolnay | 919085c | 2020-10-31 22:32:22 -0700 | [diff] [blame] | 21 | pub ptr_len: bool, |
| David Tolnay | 3be0e1f | 2020-10-31 20:53:00 -0700 | [diff] [blame] | 22 | pub rust_str_new_unchecked: bool, |
| 23 | pub rust_str_repr: bool, |
| David Tolnay | 36aa9e0 | 2020-10-31 23:08:21 -0700 | [diff] [blame] | 24 | pub rust_slice_new: bool, |
| 25 | pub rust_slice_repr: bool, |
| David Tolnay | 1f010c6 | 2020-11-01 20:27:46 -0800 | [diff] [blame] | 26 | pub exception: bool, |
| David Tolnay | 174bd95 | 2020-11-02 09:23:12 -0800 | [diff] [blame] | 27 | pub relocatable: bool, |
| David Tolnay | 22664ae | 2020-11-04 16:30:45 -0800 | [diff] [blame] | 28 | pub friend_impl: bool, |
| David Tolnay | 5346276 | 2020-11-25 07:08:10 -0800 | [diff] [blame] | 29 | pub is_complete: bool, |
| 30 | pub deleter_if: bool, |
| David Tolnay | 97c5b86 | 2020-11-01 14:59:01 -0800 | [diff] [blame] | 31 | pub content: Content<'a>, |
| David Tolnay | 3be0e1f | 2020-10-31 20:53:00 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| David Tolnay | 97c5b86 | 2020-11-01 14:59:01 -0800 | [diff] [blame] | 34 | impl<'a> Builtins<'a> { |
| David Tolnay | 3be0e1f | 2020-10-31 20:53:00 -0700 | [diff] [blame] | 35 | pub fn new() -> Self { |
| 36 | Builtins::default() |
| 37 | } |
| 38 | } |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 39 | |
| 40 | pub(super) fn write(out: &mut OutFile) { |
| 41 | if out.builtin == Default::default() { |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | let include = &mut out.include; |
| 46 | let builtin = &mut out.builtin; |
| 47 | let out = &mut builtin.content; |
| 48 | |
| David Tolnay | dcfa8e9 | 2020-11-02 09:50:06 -0800 | [diff] [blame] | 49 | if builtin.rust_string { |
| 50 | include.array = true; |
| 51 | include.cstdint = true; |
| 52 | include.string = true; |
| 53 | } |
| 54 | |
| 55 | if builtin.rust_str { |
| 56 | include.cstdint = true; |
| 57 | include.string = true; |
| David Tolnay | 22664ae | 2020-11-04 16:30:45 -0800 | [diff] [blame] | 58 | builtin.friend_impl = true; |
| 59 | } |
| 60 | |
| 61 | if builtin.rust_slice { |
| David Tolnay | d1df4c7 | 2020-11-25 20:38:05 -0800 | [diff] [blame] | 62 | include.iterator = true; |
| David Tolnay | 450d8cd | 2020-11-25 20:36:06 -0800 | [diff] [blame] | 63 | include.type_traits = true; |
| David Tolnay | 22664ae | 2020-11-04 16:30:45 -0800 | [diff] [blame] | 64 | builtin.friend_impl = true; |
| David Tolnay | dcfa8e9 | 2020-11-02 09:50:06 -0800 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | if builtin.rust_box { |
| 68 | include.new = true; |
| 69 | include.type_traits = true; |
| David Tolnay | ea6f86c | 2020-11-10 15:08:57 -0800 | [diff] [blame] | 70 | include.utility = true; |
| David Tolnay | dcfa8e9 | 2020-11-02 09:50:06 -0800 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | if builtin.rust_vec { |
| David Tolnay | f799b37 | 2020-11-29 23:57:42 -0800 | [diff] [blame] | 74 | include.algorithm = true; |
| David Tolnay | dcfa8e9 | 2020-11-02 09:50:06 -0800 | [diff] [blame] | 75 | include.array = true; |
| David Tolnay | f799b37 | 2020-11-29 23:57:42 -0800 | [diff] [blame] | 76 | include.initializer_list = true; |
| David Tolnay | d1df4c7 | 2020-11-25 20:38:05 -0800 | [diff] [blame] | 77 | include.iterator = true; |
| David Tolnay | dcfa8e9 | 2020-11-02 09:50:06 -0800 | [diff] [blame] | 78 | include.new = true; |
| 79 | include.type_traits = true; |
| David Tolnay | fb6b73c | 2020-11-10 14:32:16 -0800 | [diff] [blame] | 80 | include.utility = true; |
| David Tolnay | dcfa8e9 | 2020-11-02 09:50:06 -0800 | [diff] [blame] | 81 | builtin.panic = true; |
| 82 | builtin.unsafe_bitcopy = true; |
| 83 | } |
| 84 | |
| David Tolnay | a5a1301 | 2020-11-10 15:03:09 -0800 | [diff] [blame] | 85 | if builtin.rust_fn { |
| 86 | include.utility = true; |
| 87 | } |
| 88 | |
| David Tolnay | dcfa8e9 | 2020-11-02 09:50:06 -0800 | [diff] [blame] | 89 | if builtin.rust_error { |
| 90 | include.exception = true; |
| David Tolnay | 22664ae | 2020-11-04 16:30:45 -0800 | [diff] [blame] | 91 | builtin.friend_impl = true; |
| David Tolnay | dcfa8e9 | 2020-11-02 09:50:06 -0800 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | if builtin.rust_isize { |
| 95 | include.basetsd = true; |
| David Tolnay | 74dd66f | 2020-12-12 22:03:47 -0800 | [diff] [blame^] | 96 | include.sys_types = true; |
| David Tolnay | dcfa8e9 | 2020-11-02 09:50:06 -0800 | [diff] [blame] | 97 | } |
| 98 | |
| David Tolnay | 174bd95 | 2020-11-02 09:23:12 -0800 | [diff] [blame] | 99 | if builtin.relocatable { |
| 100 | include.type_traits = true; |
| 101 | } |
| 102 | |
| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 103 | out.begin_block(Block::Namespace("rust")); |
| David Tolnay | 0f0162f | 2020-11-16 23:43:37 -0800 | [diff] [blame] | 104 | out.begin_block(Block::InlineNamespace("cxxbridge1")); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 105 | writeln!(out, "// #include \"rust/cxx.h\""); |
| 106 | |
| David Tolnay | 0f0162f | 2020-11-16 23:43:37 -0800 | [diff] [blame] | 107 | ifndef::write(out, builtin.panic, "CXXBRIDGE1_PANIC"); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 108 | |
| 109 | if builtin.rust_string { |
| 110 | out.next_section(); |
| 111 | writeln!(out, "struct unsafe_bitcopy_t;"); |
| 112 | } |
| 113 | |
| David Tolnay | 22664ae | 2020-11-04 16:30:45 -0800 | [diff] [blame] | 114 | if builtin.friend_impl { |
| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 115 | out.begin_block(Block::AnonymousNamespace); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 116 | writeln!(out, "template <typename T>"); |
| 117 | writeln!(out, "class impl;"); |
| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 118 | out.end_block(Block::AnonymousNamespace); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| David Tolnay | 828e513 | 2020-11-29 20:40:40 -0800 | [diff] [blame] | 121 | if builtin.rust_str && !builtin.rust_string { |
| 122 | out.next_section(); |
| 123 | writeln!(out, "class String;"); |
| 124 | } |
| 125 | |
| David Tolnay | 0f0162f | 2020-11-16 23:43:37 -0800 | [diff] [blame] | 126 | ifndef::write(out, builtin.rust_string, "CXXBRIDGE1_RUST_STRING"); |
| 127 | ifndef::write(out, builtin.rust_str, "CXXBRIDGE1_RUST_STR"); |
| 128 | ifndef::write(out, builtin.rust_slice, "CXXBRIDGE1_RUST_SLICE"); |
| 129 | ifndef::write(out, builtin.rust_box, "CXXBRIDGE1_RUST_BOX"); |
| 130 | ifndef::write(out, builtin.unsafe_bitcopy, "CXXBRIDGE1_RUST_BITCOPY"); |
| 131 | ifndef::write(out, builtin.rust_vec, "CXXBRIDGE1_RUST_VEC"); |
| 132 | ifndef::write(out, builtin.rust_fn, "CXXBRIDGE1_RUST_FN"); |
| 133 | ifndef::write(out, builtin.rust_error, "CXXBRIDGE1_RUST_ERROR"); |
| 134 | ifndef::write(out, builtin.rust_isize, "CXXBRIDGE1_RUST_ISIZE"); |
| David Tolnay | 365fc7c | 2020-11-25 16:08:13 -0800 | [diff] [blame] | 135 | ifndef::write(out, builtin.opaque, "CXXBRIDGE1_RUST_OPAQUE"); |
| David Tolnay | 0f0162f | 2020-11-16 23:43:37 -0800 | [diff] [blame] | 136 | ifndef::write(out, builtin.relocatable, "CXXBRIDGE1_RELOCATABLE"); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 137 | |
| David Tolnay | 718ca0f | 2020-12-09 23:01:11 -0800 | [diff] [blame] | 138 | out.begin_block(Block::Namespace("detail")); |
| 139 | |
| 140 | if builtin.maybe_uninit { |
| 141 | include.cstddef = true; |
| 142 | include.new = true; |
| 143 | out.next_section(); |
| 144 | writeln!(out, "template <typename T, typename = void *>"); |
| 145 | writeln!(out, "struct operator_new {{"); |
| 146 | writeln!( |
| 147 | out, |
| 148 | " void *operator()(size_t sz) {{ return ::operator new(sz); }}", |
| 149 | ); |
| 150 | writeln!(out, "}};"); |
| 151 | out.next_section(); |
| 152 | writeln!(out, "template <typename T>"); |
| 153 | writeln!( |
| 154 | out, |
| 155 | "struct operator_new<T, decltype(T::operator new(sizeof(T)))> {{", |
| 156 | ); |
| 157 | writeln!( |
| 158 | out, |
| 159 | " void *operator()(size_t sz) {{ return T::operator new(sz); }}", |
| 160 | ); |
| 161 | writeln!(out, "}};"); |
| 162 | } |
| 163 | |
| 164 | out.end_block(Block::Namespace("detail")); |
| 165 | |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 166 | if builtin.manually_drop { |
| 167 | out.next_section(); |
| 168 | include.utility = true; |
| 169 | writeln!(out, "template <typename T>"); |
| 170 | writeln!(out, "union ManuallyDrop {{"); |
| 171 | writeln!(out, " T value;"); |
| 172 | writeln!( |
| 173 | out, |
| 174 | " ManuallyDrop(T &&value) : value(::std::move(value)) {{}}", |
| 175 | ); |
| 176 | writeln!(out, " ~ManuallyDrop() {{}}"); |
| 177 | writeln!(out, "}};"); |
| 178 | } |
| 179 | |
| 180 | if builtin.maybe_uninit { |
| David Tolnay | 718ca0f | 2020-12-09 23:01:11 -0800 | [diff] [blame] | 181 | include.cstddef = true; |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 182 | out.next_section(); |
| 183 | writeln!(out, "template <typename T>"); |
| 184 | writeln!(out, "union MaybeUninit {{"); |
| 185 | writeln!(out, " T value;"); |
| David Tolnay | 718ca0f | 2020-12-09 23:01:11 -0800 | [diff] [blame] | 186 | writeln!( |
| 187 | out, |
| 188 | " void *operator new(size_t sz) {{ return detail::operator_new<T>{{}}(sz); }}", |
| 189 | ); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 190 | writeln!(out, " MaybeUninit() {{}}"); |
| 191 | writeln!(out, " ~MaybeUninit() {{}}"); |
| 192 | writeln!(out, "}};"); |
| 193 | } |
| 194 | |
| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 195 | out.begin_block(Block::AnonymousNamespace); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 196 | |
| David Tolnay | 919085c | 2020-10-31 22:32:22 -0700 | [diff] [blame] | 197 | if builtin.ptr_len { |
| David Tolnay | 12320e1 | 2020-12-09 23:09:36 -0800 | [diff] [blame] | 198 | include.cstddef = true; |
| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 199 | out.begin_block(Block::Namespace("repr")); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 200 | writeln!(out, "struct PtrLen final {{"); |
| David Tolnay | c5629f0 | 2020-11-23 18:32:46 -0800 | [diff] [blame] | 201 | writeln!(out, " void *ptr;"); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 202 | writeln!(out, " size_t len;"); |
| 203 | writeln!(out, "}};"); |
| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 204 | out.end_block(Block::Namespace("repr")); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | if builtin.rust_str_new_unchecked || builtin.rust_str_repr { |
| 208 | out.next_section(); |
| 209 | writeln!(out, "template <>"); |
| 210 | writeln!(out, "class impl<Str> final {{"); |
| 211 | writeln!(out, "public:"); |
| 212 | if builtin.rust_str_new_unchecked { |
| 213 | writeln!( |
| 214 | out, |
| 215 | " static Str new_unchecked(repr::PtrLen repr) noexcept {{", |
| 216 | ); |
| 217 | writeln!(out, " Str str;"); |
| 218 | writeln!(out, " str.ptr = static_cast<const char *>(repr.ptr);"); |
| 219 | writeln!(out, " str.len = repr.len;"); |
| 220 | writeln!(out, " return str;"); |
| 221 | writeln!(out, " }}"); |
| 222 | } |
| 223 | if builtin.rust_str_repr { |
| 224 | writeln!(out, " static repr::PtrLen repr(Str str) noexcept {{"); |
| David Tolnay | c5629f0 | 2020-11-23 18:32:46 -0800 | [diff] [blame] | 225 | writeln!( |
| 226 | out, |
| 227 | " return repr::PtrLen{{const_cast<char *>(str.ptr), str.len}};", |
| 228 | ); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 229 | writeln!(out, " }}"); |
| 230 | } |
| 231 | writeln!(out, "}};"); |
| 232 | } |
| 233 | |
| David Tolnay | 36aa9e0 | 2020-10-31 23:08:21 -0700 | [diff] [blame] | 234 | if builtin.rust_slice_new || builtin.rust_slice_repr { |
| 235 | out.next_section(); |
| 236 | writeln!(out, "template <typename T>"); |
| 237 | writeln!(out, "class impl<Slice<T>> final {{"); |
| 238 | writeln!(out, "public:"); |
| 239 | if builtin.rust_slice_new { |
| 240 | writeln!( |
| 241 | out, |
| 242 | " static Slice<T> slice(repr::PtrLen repr) noexcept {{", |
| 243 | ); |
| David Tolnay | c5629f0 | 2020-11-23 18:32:46 -0800 | [diff] [blame] | 244 | writeln!(out, " return {{static_cast<T *>(repr.ptr), repr.len}};"); |
| David Tolnay | 36aa9e0 | 2020-10-31 23:08:21 -0700 | [diff] [blame] | 245 | writeln!(out, " }}"); |
| 246 | } |
| 247 | if builtin.rust_slice_repr { |
| David Tolnay | c5629f0 | 2020-11-23 18:32:46 -0800 | [diff] [blame] | 248 | include.type_traits = true; |
| David Tolnay | 36aa9e0 | 2020-10-31 23:08:21 -0700 | [diff] [blame] | 249 | writeln!( |
| 250 | out, |
| 251 | " static repr::PtrLen repr(Slice<T> slice) noexcept {{", |
| 252 | ); |
| David Tolnay | c5629f0 | 2020-11-23 18:32:46 -0800 | [diff] [blame] | 253 | writeln!(out, " return repr::PtrLen{{"); |
| 254 | writeln!( |
| 255 | out, |
| 256 | " const_cast<typename ::std::remove_const<T>::type *>(slice.ptr),", |
| 257 | ); |
| 258 | writeln!(out, " slice.len}};"); |
| David Tolnay | 36aa9e0 | 2020-10-31 23:08:21 -0700 | [diff] [blame] | 259 | writeln!(out, " }}"); |
| 260 | } |
| 261 | writeln!(out, "}};"); |
| 262 | } |
| 263 | |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 264 | if builtin.rust_error { |
| 265 | out.next_section(); |
| 266 | writeln!(out, "template <>"); |
| 267 | writeln!(out, "class impl<Error> final {{"); |
| 268 | writeln!(out, "public:"); |
| 269 | writeln!(out, " static Error error(repr::PtrLen repr) noexcept {{"); |
| 270 | writeln!(out, " Error error;"); |
| 271 | writeln!(out, " error.msg = static_cast<const char *>(repr.ptr);"); |
| 272 | writeln!(out, " error.len = repr.len;"); |
| 273 | writeln!(out, " return error;"); |
| 274 | writeln!(out, " }}"); |
| 275 | writeln!(out, "}};"); |
| 276 | } |
| 277 | |
| David Tolnay | 5346276 | 2020-11-25 07:08:10 -0800 | [diff] [blame] | 278 | if builtin.is_complete { |
| David Tolnay | 12320e1 | 2020-12-09 23:09:36 -0800 | [diff] [blame] | 279 | include.cstddef = true; |
| David Tolnay | 5346276 | 2020-11-25 07:08:10 -0800 | [diff] [blame] | 280 | include.type_traits = true; |
| 281 | out.next_section(); |
| 282 | writeln!(out, "template <typename T, typename = size_t>"); |
| 283 | writeln!(out, "struct is_complete : std::false_type {{}};"); |
| 284 | out.next_section(); |
| 285 | writeln!(out, "template <typename T>"); |
| 286 | writeln!( |
| 287 | out, |
| 288 | "struct is_complete<T, decltype(sizeof(T))> : std::true_type {{}};", |
| 289 | ); |
| 290 | } |
| 291 | |
| 292 | if builtin.deleter_if { |
| 293 | out.next_section(); |
| 294 | writeln!(out, "template <bool> struct deleter_if {{"); |
| 295 | writeln!(out, " template <typename T> void operator()(T *) {{}}"); |
| 296 | writeln!(out, "}};"); |
| 297 | out.next_section(); |
| 298 | writeln!(out, "template <> struct deleter_if<true> {{"); |
| 299 | writeln!( |
| 300 | out, |
| 301 | " template <typename T> void operator()(T *ptr) {{ ptr->~T(); }}", |
| 302 | ); |
| 303 | writeln!(out, "}};"); |
| 304 | } |
| 305 | |
| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 306 | out.end_block(Block::AnonymousNamespace); |
| David Tolnay | 0f0162f | 2020-11-16 23:43:37 -0800 | [diff] [blame] | 307 | out.end_block(Block::InlineNamespace("cxxbridge1")); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 308 | |
| 309 | if builtin.trycatch { |
| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 310 | out.begin_block(Block::Namespace("behavior")); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 311 | include.exception = true; |
| 312 | include.type_traits = true; |
| 313 | include.utility = true; |
| 314 | writeln!(out, "class missing {{}};"); |
| 315 | writeln!(out, "missing trycatch(...);"); |
| 316 | writeln!(out); |
| 317 | writeln!(out, "template <typename Try, typename Fail>"); |
| 318 | writeln!(out, "static typename ::std::enable_if<"); |
| 319 | writeln!( |
| 320 | out, |
| 321 | " ::std::is_same<decltype(trycatch(::std::declval<Try>(), ::std::declval<Fail>())),", |
| 322 | ); |
| 323 | writeln!(out, " missing>::value>::type"); |
| 324 | writeln!(out, "trycatch(Try &&func, Fail &&fail) noexcept try {{"); |
| 325 | writeln!(out, " func();"); |
| 326 | writeln!(out, "}} catch (const ::std::exception &e) {{"); |
| 327 | writeln!(out, " fail(e.what());"); |
| 328 | writeln!(out, "}}"); |
| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 329 | out.end_block(Block::Namespace("behavior")); |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 330 | } |
| 331 | |
| David Tolnay | 0c033e3 | 2020-11-01 15:15:48 -0800 | [diff] [blame] | 332 | out.end_block(Block::Namespace("rust")); |
| David Tolnay | 1f010c6 | 2020-11-01 20:27:46 -0800 | [diff] [blame] | 333 | |
| 334 | if builtin.exception { |
| David Tolnay | 12320e1 | 2020-12-09 23:09:36 -0800 | [diff] [blame] | 335 | include.cstddef = true; |
| David Tolnay | 1f010c6 | 2020-11-01 20:27:46 -0800 | [diff] [blame] | 336 | out.begin_block(Block::ExternC); |
| 337 | writeln!( |
| 338 | out, |
| David Tolnay | 0f0162f | 2020-11-16 23:43:37 -0800 | [diff] [blame] | 339 | "const char *cxxbridge1$exception(const char *, size_t);", |
| David Tolnay | 1f010c6 | 2020-11-01 20:27:46 -0800 | [diff] [blame] | 340 | ); |
| 341 | out.end_block(Block::ExternC); |
| 342 | } |
| David Tolnay | 3374d8d | 2020-10-31 22:18:45 -0700 | [diff] [blame] | 343 | } |