-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathfunctions_cc_api.h
More file actions
352 lines (283 loc) · 12.4 KB
/
functions_cc_api.h
File metadata and controls
352 lines (283 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
// Part of the Crubit project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// Automatically @generated C++ bindings for the following Rust crate:
// functions_golden
// Features: assume_lifetimes, callables, check_default_initialized,
// experimental, supported, unsafe_view, wrapper
// clang-format off
#ifndef THIRD_PARTY_CRUBIT_CC_BINDINGS_FROM_RS_TEST_FUNCTIONS_FUNCTIONS_GOLDEN
#define THIRD_PARTY_CRUBIT_CC_BINDINGS_FROM_RS_TEST_FUNCTIONS_FUNCTIONS_GOLDEN
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
#pragma clang diagnostic ignored "-Wunused-private-field"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#include "support/annotations_internal.h"
#include "support/internal/cxx20_backports.h"
#include "support/lifetime_annotations.h"
#include "support/rs_std/char.h"
#include <cstdint>
namespace functions::fn_abi_tests {
// Testing `#[unsafe(export_name = ...)]` - the generated bindings need to
// forward/proxy the call into a function with a different name.
//
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=27
std::int32_t add_i32_via_extern_c_with_export_name(std::int32_t x,
std::int32_t y);
// Testing bindings for an `extern "C"` function (no thunk required) with a
// mangled name. This test verifies that:
// * `cc_bindings_from_rs` can correctly discover mangled names that
// `rustc` produces
// * Bazel support for `cc_bindings_from_rs` invokes it with the same
// command line flags as the ones used when invoking `rustc` when
// building the `functions` crate.
//
// TODO(b/262904507): Bazel integration is currently broken and the
// coresponding test is commented out in `functions_test.cc`.
//
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=41
std::int32_t add_i32_via_extern_c_with_mangling(std::int32_t x, std::int32_t y);
// Testing the default / Rust ABI (one used in absence of `extern "C"`).
//
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=46
std::int32_t add_i32_via_rust_abi(std::int32_t x, std::int32_t y);
// Testing one of simpler function bindings:
// - `extern "C"` means that no thunk is required
// - `#[unsafe(no_mangle)]` means that the function is already exposed with
// the desired, public name (and just needs to be redeclared in C++).
//
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=20
extern "C" double get_42_as_f64_via_no_mangle_extern_c();
} // namespace functions::fn_abi_tests
namespace functions::fn_attribute_tests {
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=128
[[deprecated("★ Deprecated note for add_i32 ★")]] std::int32_t add_i32(
std::int32_t x, std::int32_t y);
} // namespace functions::fn_attribute_tests
namespace functions::fn_must_use_tests {
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=151
[[nodiscard("woohoo")]] std::int32_t msg_add(std::int32_t x, std::int32_t y);
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=146
[[nodiscard]] std::int32_t no_msg_add(std::int32_t x, std::int32_t y);
} // namespace functions::fn_must_use_tests
namespace functions::fn_param_ty_tests {
// Testing a type that maps to a built-in C++ type (spelled with a
// keyword). `float` is one such example.
//
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=55
double add_f64(double x, double y);
// Testing a type that requires `#include`ing a standard C++ header.
// `std::int32_t` is one such example - it requires `#include <cstdint>`.
//
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=61
std::int32_t add_i32(std::int32_t x, std::int32_t y);
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=65
void add_i32_via_ptr(std::int32_t const* x, std::int32_t const* y,
std::int32_t* sum);
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=80
std::int32_t apply_binary_i32_op(
std::int32_t x, std::int32_t y,
crubit::type_identity_t<std::int32_t(std::int32_t, std::int32_t)>& f);
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=72
rs_std::char_ char_to_ascii_lowercase(rs_std::char_ c);
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=92
std::int32_t const& $(__anon1) get_identical_ref_with_inferred_lifetime(
std::int32_t const* $(__anon1) crubit_nonnull x CRUBIT_LIFETIME_BOUND);
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=84
std::int32_t const& $a
get_ref_to_smaller_int(std::int32_t const* $a crubit_nonnull x,
std::int32_t const* $a crubit_nonnull y);
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=96
void set_mut_ref_to_sum_of_ints(std::int32_t& sum, std::int32_t x,
std::int32_t y);
} // namespace functions::fn_param_ty_tests
namespace functions::other_fn_param_tests {
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=121
std::int32_t add_i32_via_rust_abi_with_duplicated_param_names(
std::int32_t x, std::int32_t y, std::int32_t __param_2,
std::int32_t __param_3);
} // namespace functions::other_fn_param_tests
namespace functions::unit_ret_ty_tests {
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=115
extern "C" std::int32_t get_global_i32_via_extern_c_with_export_name();
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=110
void set_global_i32_via_extern_c_with_export_name(std::int32_t x);
} // namespace functions::unit_ret_ty_tests
namespace functions::unsafe_fn_tests {
// # Safety
//
// This function has no safety requirements - it is only marked as `unsafe`
// to facilitate minimal testing of bindings generated for such functions.
//
// Generated from:
// cc_bindings_from_rs/test/functions/functions.rs;l=138
std::int32_t unsafe_add(std::int32_t x, std::int32_t y);
} // namespace functions::unsafe_fn_tests
namespace functions::fn_abi_tests {
namespace __crubit_internal {
extern "C" std::int32_t custom_export_name_for_add_i32(std::int32_t,
std::int32_t);
}
inline std::int32_t add_i32_via_extern_c_with_export_name(std::int32_t x,
std::int32_t y) {
return __crubit_internal::custom_export_name_for_add_i32(x, y);
}
namespace __crubit_internal {
extern "C" std::int32_t __crubit_thunk_add_ui32_uvia_uextern_uc_uwith_umangling(
std::int32_t, std::int32_t);
}
inline std::int32_t add_i32_via_extern_c_with_mangling(std::int32_t x,
std::int32_t y) {
return __crubit_internal::
__crubit_thunk_add_ui32_uvia_uextern_uc_uwith_umangling(x, y);
}
namespace __crubit_internal {
extern "C" std::int32_t __crubit_thunk_add_ui32_uvia_urust_uabi(std::int32_t,
std::int32_t);
}
inline std::int32_t add_i32_via_rust_abi(std::int32_t x, std::int32_t y) {
return __crubit_internal::__crubit_thunk_add_ui32_uvia_urust_uabi(x, y);
}
} // namespace functions::fn_abi_tests
namespace functions::fn_attribute_tests {
namespace __crubit_internal {
extern "C" std::int32_t __crubit_thunk_add_ui32(std::int32_t, std::int32_t);
}
inline std::int32_t add_i32(std::int32_t x, std::int32_t y) {
return __crubit_internal::__crubit_thunk_add_ui32(x, y);
}
} // namespace functions::fn_attribute_tests
namespace functions::fn_must_use_tests {
namespace __crubit_internal {
extern "C" std::int32_t __crubit_thunk_msg_uadd(std::int32_t, std::int32_t);
}
inline std::int32_t msg_add(std::int32_t x, std::int32_t y) {
return __crubit_internal::__crubit_thunk_msg_uadd(x, y);
}
namespace __crubit_internal {
extern "C" std::int32_t __crubit_thunk_no_umsg_uadd(std::int32_t, std::int32_t);
}
inline std::int32_t no_msg_add(std::int32_t x, std::int32_t y) {
return __crubit_internal::__crubit_thunk_no_umsg_uadd(x, y);
}
} // namespace functions::fn_must_use_tests
namespace functions::fn_param_ty_tests {
namespace __crubit_internal {
extern "C" double __crubit_thunk_add_uf64(double, double);
}
inline double add_f64(double x, double y) {
return __crubit_internal::__crubit_thunk_add_uf64(x, y);
}
namespace __crubit_internal {
extern "C" std::int32_t __crubit_thunk_add_ui32(std::int32_t, std::int32_t);
}
inline std::int32_t add_i32(std::int32_t x, std::int32_t y) {
return __crubit_internal::__crubit_thunk_add_ui32(x, y);
}
namespace __crubit_internal {
extern "C" void __crubit_thunk_add_ui32_uvia_uptr(std::int32_t const*,
std::int32_t const*,
std::int32_t*);
}
inline void add_i32_via_ptr(std::int32_t const* x, std::int32_t const* y,
std::int32_t* sum) {
return __crubit_internal::__crubit_thunk_add_ui32_uvia_uptr(x, y, sum);
}
namespace __crubit_internal {
extern "C" std::int32_t __crubit_thunk_apply_ubinary_ui32_uop(
std::int32_t, std::int32_t,
crubit::type_identity_t<std::int32_t(std::int32_t, std::int32_t)>&);
}
inline std::int32_t apply_binary_i32_op(
std::int32_t x, std::int32_t y,
crubit::type_identity_t<std::int32_t(std::int32_t, std::int32_t)>& f) {
return __crubit_internal::__crubit_thunk_apply_ubinary_ui32_uop(x, y, f);
}
namespace __crubit_internal {
extern "C" rs_std::char_ __crubit_thunk_char_uto_uascii_ulowercase(
rs_std::char_);
}
inline rs_std::char_ char_to_ascii_lowercase(rs_std::char_ c) {
return __crubit_internal::__crubit_thunk_char_uto_uascii_ulowercase(c);
}
namespace __crubit_internal {
extern "C" std::int32_t const& $(__anon1)
__crubit_thunk_get_uidentical_uref_uwith_uinferred_ulifetime(
std::int32_t const* $(__anon1) crubit_nonnull);
}
inline std::int32_t const& $(__anon1) get_identical_ref_with_inferred_lifetime(
std::int32_t const* $(__anon1) crubit_nonnull x CRUBIT_LIFETIME_BOUND) {
return __crubit_internal::
__crubit_thunk_get_uidentical_uref_uwith_uinferred_ulifetime(x);
}
namespace __crubit_internal {
extern "C" std::int32_t const& $a __crubit_thunk_get_uref_uto_usmaller_uint(
std::int32_t const* $a crubit_nonnull,
std::int32_t const* $a crubit_nonnull);
}
inline std::int32_t const& $a
get_ref_to_smaller_int(std::int32_t const* $a crubit_nonnull x,
std::int32_t const* $a crubit_nonnull y) {
return __crubit_internal::__crubit_thunk_get_uref_uto_usmaller_uint(x, y);
}
namespace __crubit_internal {
extern "C" void __crubit_thunk_set_umut_uref_uto_usum_uof_uints(std::int32_t&,
std::int32_t,
std::int32_t);
}
inline void set_mut_ref_to_sum_of_ints(std::int32_t& sum, std::int32_t x,
std::int32_t y) {
return __crubit_internal::__crubit_thunk_set_umut_uref_uto_usum_uof_uints(
sum, x, y);
}
} // namespace functions::fn_param_ty_tests
namespace functions::other_fn_param_tests {
namespace __crubit_internal {
extern "C" std::int32_t
__crubit_thunk_add_ui32_uvia_urust_uabi_uwith_uduplicated_uparam_unames(
std::int32_t, std::int32_t, std::int32_t, std::int32_t);
}
inline std::int32_t add_i32_via_rust_abi_with_duplicated_param_names(
std::int32_t x, std::int32_t y, std::int32_t __param_2,
std::int32_t __param_3) {
return __crubit_internal::
__crubit_thunk_add_ui32_uvia_urust_uabi_uwith_uduplicated_uparam_unames(
x, y, __param_2, __param_3);
}
} // namespace functions::other_fn_param_tests
namespace functions::unit_ret_ty_tests {
namespace __crubit_internal {
extern "C" void custom_export_name_for_get_global_i32(std::int32_t);
}
inline void set_global_i32_via_extern_c_with_export_name(std::int32_t x) {
return __crubit_internal::custom_export_name_for_get_global_i32(x);
}
} // namespace functions::unit_ret_ty_tests
namespace functions::unsafe_fn_tests {
namespace __crubit_internal {
extern "C" std::int32_t __crubit_thunk_unsafe_uadd(std::int32_t, std::int32_t);
}
inline std::int32_t unsafe_add(std::int32_t x, std::int32_t y) {
return __crubit_internal::__crubit_thunk_unsafe_uadd(x, y);
}
} // namespace functions::unsafe_fn_tests
#pragma clang diagnostic pop
#endif // THIRD_PARTY_CRUBIT_CC_BINDINGS_FROM_RS_TEST_FUNCTIONS_FUNCTIONS_GOLDEN