Commit Graph

3312 Commits

Author SHA1 Message Date
Christian Poveda
06a6479e9e
s/static/const 2022-09-26 11:02:42 -05:00
Christian Poveda
4312df317a
update CONTRIBUTING.md 2022-09-26 10:55:05 -05:00
Christian Poveda
76e8fa29f9
Merge remote-tracking branch 'emilio/less-macro-magic' into sovereign-module-of-syn 2022-09-26 10:50:46 -05:00
Emilio Cobos Álvarez
0798bdaccf
Clean-up postprocessing to use less macro magic. 2022-09-23 18:11:45 -10:00
Christian Poveda
3dfbc602ae
update CONTRIBUTING.md section about syn 2022-09-23 18:00:58 -10:00
Christian Poveda
a372499b93
move codegen postprocessing to its own module 2022-09-23 18:00:57 -10:00
Christian Poveda
2963d057ee
Merge pull request #2283 from ferrous-systems/remove-file
Remove file added by mistake
2022-09-23 21:37:54 -05:00
Christian Poveda
45b9c34302
remove file added by mistake 2022-09-23 21:29:17 -05:00
Christian Poveda
1b7e4705dd
Merge pull request #2278 from ferrous-systems/size_t
Map size_t to usize by default and check compatibility [Rebased]
2022-09-23 21:21:17 -05:00
Geoffrey Thomas
cc78b6fdb6
Map size_t to usize by default and check compatibility (fixes #1901, #1903)
This addresses the underlying issue identified in #1671, that size_t
(integer that can hold any object size) isn't guaranteed to match usize,
which is defined more like uintptr_t (integer that can hold any
pointer). However, on almost all platforms, this is true, and in fact
Rust already uses usize extensively in contexts where size_t would be
more appropriate, such as slice indexing. So, it's better for ergonomics
when interfacing with C code to map the C size_t type to usize. (See
also discussion in rust-lang/rust#65473 about how usize really should be
defined as size_t, not uintptr_t.)

The previous fix for #1671 removed the special case for size_t and
defaulted to binding it as a normal typedef.  This change effectively
reverts that and goes back to mapping size_t to usize (and ssize_t to
isize), but also ensures that if size_t is emitted, the typedef'd type
of size_t in fact is compatible with usize (defined by checking that the
size and alignment match the target pointer width). For (hypothetical)
platforms where this is not true, or for compatibility with the default
behavior of bindgen between 0.53 and this commit, onwards, you can
disable this mapping with --no-size_t-is-usize.
2022-09-23 21:13:37 -05:00
Christian Poveda
0e4c1ae92c
update CONTRIBUTING.md section about syn 2022-09-23 15:24:19 -05:00
Christian Poveda
e1f314eb44
move codegen postprocessing to its own module 2022-09-23 15:20:56 -05:00
Emilio Cobos Álvarez
6de2d3d1c1 features: Bump LATEST_STABLE_RUST after #2267. 2022-09-22 21:50:57 -10:00
Christian Poveda
0f3b8a840c update to rust 1.64 2022-09-22 21:18:25 -10:00
Christian Poveda
995943ce06 put tests behind the nightly feature 2022-09-22 21:18:25 -10:00
Christian Poveda
3ec5c87462 use #[feature(core_ffi_c)] when available 2022-09-22 21:18:25 -10:00
Amanjeev Sethi
c84897d338 test: add test for GH-422
GitHub issue 422 was fixed but needs a test.
https://github.com/rust-lang/rust-bindgen/issues/422

Signed-off-by: Amanjeev Sethi <aj@amanjeev.com>
2022-09-22 21:10:33 -10:00
Emilio Cobos Álvarez
af12c29026 codegen: Implement manuallydrop fields better.
This doesn't change behavior but makes the code make more sense.
2022-09-22 21:10:02 -10:00
Christian Poveda
4b006da21b
Add option to deduplicate extern blocks (#2258) 2022-09-23 09:04:28 +02:00
Poliorcetics
04c0cd0ff4
Option to wrap union members in ManuallyDrop (#2185) 2022-09-23 08:30:49 +02:00
Christian Poveda
86f059f081 add the -- -std=c++11 flag 2022-09-22 20:25:33 -10:00
Christian Poveda
953acc526a handle __attribute__((noreturn)) attribute 2022-09-22 20:25:33 -10:00
Christian Poveda
2ffc8d8946 handle c++ [[noreturn]] attribute 2022-09-22 20:25:33 -10:00
Christian Poveda
e503476a96 bring back optional cursor kind 2022-09-22 20:25:33 -10:00
Christian Poveda
fb5f9b963c document has_attrs 2022-09-22 20:25:33 -10:00
Christian Poveda
15f5094d45 document Attribute 2022-09-22 20:25:33 -10:00
Christian Poveda
2251aed4d0 find all attributes in a single pass 2022-09-22 20:25:33 -10:00
Christian Poveda
3da6026afd gate _Noreturn detection behind --enable-fucntion-attribute-detection 2022-09-22 20:25:33 -10:00
Christian Poveda
b8f3920ad1 add CxTokenKind argument to has_attr 2022-09-22 20:25:33 -10:00
Christian Poveda
1704775d91 add tests 2022-09-22 20:25:33 -10:00
Christian Poveda
250150d015 check for noreturn attribute 2022-09-22 20:25:33 -10:00
Christian Poveda
6a100c0b32 add is_divergent field 2022-09-22 20:25:33 -10:00
Christian Poveda
0d805d70d5 fix --newtype-global-enum option 2022-09-18 20:11:42 -04:00
Christian Poveda
61636e94ca add --newtype-global-enum option 2022-09-11 09:27:58 -04:00
Christian Poveda
8b29355ca0 document usage of syn in CONTRIBUTING.md 2022-09-09 21:16:42 -04:00
Christian Poveda
7464da3845 add BindgenOptions::require_syn method 2022-09-09 21:16:42 -04:00
Justin Smith
5209ebdbdf Fix formatting 2022-09-09 11:57:38 -04:00
Justin Smith
df74d0e3f7 Use str::strip_prefix 2022-09-09 11:44:55 -04:00
Justin W Smith
a8f2634cf6
Merge branch 'rust-lang:master' into generated_name_override 2022-09-09 08:49:01 -04:00
Christian Poveda
9677e412c4 fix clippy lints 2022-09-08 22:14:58 -04:00
Christian Poveda
3842b11b8a replace the TraversalPredicate trait with an alias type 2022-09-05 17:13:04 +02:00
Christian Poveda
2aa244f8fc address clippy lints 2022-09-01 18:57:50 +02:00
Collin Baker
a5848cf44e Generate opaque type for template param dependent bit field width
libclang's API does not provide a straightforward way to check for
this, and calling clang_getFieldDeclBitWidth is actively unsafe in
this case. See https://github.com/llvm/llvm-project/issues/56644

We probably can't generate reasonable bindings for such a type, so
make the binding opaque.

Ideally libclang would report if the bit width could not be
evaluated. Unfortunately making such a change would mean bumping the
minimum libclang version from 6.0 to 15.0.

Instead, add logic to traverse the AST subtree starting from the
field's bit width specifier looking for template parameters. If we
find one, we make the resulting type opaque.
2022-08-25 22:19:06 +02:00
Amanjeev Sethi
6dfc3e70df
Sorting the output semantically (#2254)
Generated code needs some sorting in a way that is
semantically appealing. The request[1] asks for basic
sorting like "types are declared first, then all structs,
then all consts, then all function signatures, etc.

[1] https://github.com/rust-lang/rust-bindgen/issues/1743

Signed-off-by: Amanjeev Sethi <aj@amanjeev.com>
Co-authored-by: Christian Poveda <christian.poveda@ferrous-systems.com>
Co-authored-by: Darren Kulp <darren@kulp.ch>
2022-08-25 00:45:03 +02:00
Christian Poveda
ebb1ce98c6 rustfmt 2022-08-18 18:08:37 +02:00
Christian Poveda
89269026da emit warnings later 2022-08-18 18:08:37 +02:00
Christian Poveda
bc19e553da remove macro in favor of a method 2022-08-18 18:08:37 +02:00
Christian Poveda
c5995bda24 test warning emission 2022-08-18 18:08:37 +02:00
Christian Poveda
15a720bafa store warnings and emit them later 2022-08-18 18:08:37 +02:00
Amanjeev Sethi
50878f37e6 docs(CONTRIBUTING): add a note for single test run
test-one.sh needs to run `dot` command which is installed via Graphviz.
Else, running the script throws error - `dot` command not found.
2022-08-11 14:36:22 -05:00