Christian Poveda Ruiz
0631a27bee
Fix clippy warnings ( #2336 )
2022-11-04 15:41:49 -05:00
Christian Poveda Ruiz
e8ffb42ab6
Wrap unsafe
function's bodies in unsafe
blocks ( #2266 )
...
This guarantees that bindings generated by `bindgen` compile even if the `unsafe_op_in_unsafe_fn` lint is denied.
2022-11-04 15:22:49 -05:00
Christian Poveda Ruiz
bae6170907
Clean the implementation of Default
for BindgenOptions
( #2332 )
...
* Clean the implementation of `Default` for `BindgenOptions`
2022-11-04 13:08:14 -05:00
Christian Poveda Ruiz
7c26cd218d
Add support for the "C-unwind"
ABI ( #2334 )
...
* Add support for the `"C-unwind"` ABI
This allows using `"C-unwind"` as an ABI override if the rust target is
nightly.
2022-11-04 10:19:28 -05:00
Christian Poveda Ruiz
9c32b46048
Add the --override-abi
option ( #2329 )
...
* Add the `--override-abi` option.
This option can be used from the CLI with the <abi>:<regex> syntax and
it overrides the ABI of a function if it matches <regex>.
Fixes #2257
2022-11-02 15:30:34 -05:00
Christian Poveda Ruiz
a673a6bc9b
Allow callback composition ( #2330 )
...
* Allow callback composition
Store all the callbacks added to the builder in a `Vec` so bindgen
invokes each one of them in a last-to-first manner.
2022-11-02 13:46:22 -05:00
Christian Poveda Ruiz
83426897af
Fix clippy warnings ( #2331 )
2022-11-02 13:32:32 -05:00
Christian Poveda Ruiz
a2fe04cbaf
Add a mechanism to rerun bindgen with the same user options ( #2292 )
...
* Run `Bindings::generate` again if required.
This adds a mechanism so `bindgen` is able to run `Bindings::generate`
multiple times with the same user input if the `generate_static_inline`
option is enabled and `GenerateResult::ShouldRestart` is returned by
`Bindings::generate`.
This is done to eventually solve #1090 which would require to check for
any static inline functions and generate a new header file to be used as
an extra input and run `Bindings::generate` again.
2022-11-01 08:49:57 -05:00
Christian Poveda Ruiz
4f92dfb7c5
Add tutorial about non-system libraries ( #2318 )
...
* add tutorial about non-system libraries
* fix broken comment
* ignore code snippet
2022-11-01 08:16:41 -05:00
Charlie Barto
b3ac3efcf9
Replace confusing note in cpp.md on "RVO"
...
The original commit adding this note referenced #778 , but then went on to talk about how the problem was RVO and that the problem is not possible to solve in bindgen because bindgen can't know if RVO happened or not. However this is incorrect in several ways. The problem in #778 has nothing whatsoever to do with RVO but rather with bindgen simply not understanding the calling convention for passing or returning types that are "non trivial for the purposes of calls". This is completely consistent and does not depend on what the optimizer decided to do (after all, if callsite side calling-convention did depend on what the optimizer happened to do inside the function it would be impossible for C++ compilers to emit correct calls to external C++ functions!).
You can see this quite clearly [here](https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1DIApACYAQuYukl9ZATwDKjdAGFUtAK4sGIM6SuADJ4DJgAcj4ARpjEEgDspAAOqAqETgwe3r7%2ByanpAiFhkSwxcVyJdpgOGUIETMQEWT5%2BAVU1AnUNBEUR0bEJtvWNzTltwz2hfaUDFQCUtqhexMjsHAD06wDUACoAnkmYW3tLxFtoWFsIsZikWyRbtKhM6FuGW5iqrEn0AHQmGgAggoCMQvA4tgRMCCokwlFsTPErPEACImADMViBILBEKhIIRSIBgK2pMh0IIEDmGKxJLJ%2BMpaAYBIZ5gAbNTMcSyVsAG6oPDoABUkJpxMRaK5QIZWwUAEcvA1MFTCbSeTKCIjkZK1WTiJgCMsGKKpYCJeKgaECFsWExQiqtdz6RTIQj0SjZQqlVSxUCnaT9YbiMa0gAvTCoKgQBmc2kSjgLWicACsvD8HC0pFQnDc1msstOqwRZnRPFIBE0CYWAGsQOj0b9603my22fpOJI05Ws5xeAoQBpy5WFnBYEg0CwknRYuRKBOp/Q4sAFMwkgoEKgCKQsLy8KsAGp4TAAdwA8od02WaLQocR%2BxAot2oqEGntOGWJ2xBKeGLQ3xneCwW0jHEADtzwfUal5aFu0%2BaovChd9eCtTAkzA2g8CiYhXw8LBu1BPAWCQhYqAMZdDxPc9GCQmRBBEMR2CkWj5CUNRu10Lh9EMYw80sfRMP7SAFlQJJHAEfsOD7VDqjEvwIFcUY/E44IphKMo9BSNJZMUjT8lk3o1NmWxpI6BguhGTwWj0dpZPMyZin6cohm6HTOJBboDMciQFgUQtGMTFMuzA7MOC2VQAA42QAWjZSQtmAZBkC2aMwQYas5mS3BCAecxSzmXgKwAuYazrBsW3Kps2zQztSHTTMQr7AchyK0hR0QFBUEnacyAoCB526kBl1XddN23TBdwPI8zwvGjr1ve9HzA59mGIf8P06r8CB/P9uyA7jQMzfBIMcaCJMzODkAQtYyxQtDMwwrCcIwNZMwIojuATPgyIUCjpuoj7mPo8QmP4QRFBUdQwN0AIDCMFBeJsB7BKpLNRIyCSoqoBhUCi1DBUwKKmRxcEiDvKT7FklwGHcSycmU6nPJmJzNIKTJaaUvItIyRn1LckzbImVzjIp2oJh5oz3Is7IOcl%2Bzpl5ny/O89sOFTWruxCsLIpiuKEqSlKvDSjKICy0nizygrhxK%2BtGwq8qVZqureAa2wmsKrRipVswgvq3tmo9hZoLvDIQEkIA ) Notice how the body of `main` is identical no matter if copy elision is enabled or not. To get `test` passed in a register you must remove the copy constructor.
I spent a few hours being really confused by this note before I tracked down the original PR and realized what it was trying to talk about. Hopefully this saves the next person to come across it the same trouble.
As an aside I suspect the clang c bindings can already give you information on special member functions and base classes, making it fairly easy to do this correctly. AFAICT bindgen already does not rely on llvm's code generation facilities to figure out the ABI of calls for C (except perhaps indirectly, via rustc), so this seems reasonable to just do in bindgen, explicitly.
2022-10-31 11:09:27 +01:00
Christian Poveda Ruiz
d86db07859
Update README.md
2022-10-24 15:31:02 -05:00
Christian Poveda Ruiz
da548d20f4
Avoid suppressing panic messages ( #2323 )
...
* print `PanicInfo` using hook
* update changelog
2022-10-24 11:52:46 -05:00
Adam Gausmann
6086694d40
Sanitize RegexSet input so alternation is properly handled ( #1756 )
...
* tests: Avoid using globs as regexes
* Sanitize regex set input to properly handle alternation
* Add test case for alternates/anchors interaction
* emit warning if wildcard pattern is used
* update changelog and bump versions
Co-authored-by: Darren Kulp <darren@kulp.ch>
Co-authored-by: Christian Poveda <christian.poveda@ferrous-systems.com>
2022-10-24 10:39:52 -05:00
Christian Poveda Ruiz
170b79c88e
Merge pull request #2321 from GKFX/private_fields
...
Document visibility annotation
2022-10-24 10:04:26 -05:00
George Bateman
fc56c70500
Make doctests pass
2022-10-23 00:13:47 +01:00
George Bateman
caffa9b7ab
Document visibility annotation
2022-10-23 00:04:31 +01:00
Darren Kulp
3994a3315e
Remove Travis-CI badges
...
Travis-CI was fully removed as of faf8b3edba
.
The only badge now [mentioned in the Cargo book][1] is `maintenance`. The
`travis-ci` badge reference was [removed from Cargo two years ago][2]. The
Cargo book advises putting badges in README.md instead.
[1]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-badges-section
[2]: 60779a006f
2022-10-22 18:45:03 +02:00
Emilio Cobos Álvarez
80738016a3
clang: Detect anonymous items explicitly, rather than relying on empty names.
...
In Clang 16, anonymous items may return names like
`(anonymous union at ..)` rather than empty names.
The right way to detect them is using clang_Cursor_isAnonymous.
Fixes #2312
Closes #2316
Co-Authored-by: Patrick Walton <pcwalton@fb.com>
2022-10-22 14:24:01 +02:00
Christian Poveda
0142c0aaf7
Use panic hooks instead of using catch_unwind
...
One of the advantages of doing this is that `ParseCallbacks` no longer
needs to implement `UnwindSafe` which means that users can rely on
`RefCell` and `Cell` to extract information from the callbacks.
Users relying on `catch_unwind` can still achieve similar behavior using
`std:🧵 :spawn`.
Fixes #2147 .
2022-10-22 13:11:45 +02:00
Christian Poveda Ruiz
61ced32b93
Merge pull request #2315 from ferrous-systems/book-custom-target
...
Add FAQ about custom targets
2022-10-20 13:48:50 -05:00
Christian Poveda
c2d6f43a23
add FAQ about custom targets
2022-10-20 12:11:56 -05:00
Christian Poveda
68c741d42d
Merge pull request #2313 from ferrous-systems/fix-clippy-lints
...
Fix clippy lints
2022-10-18 12:19:40 -05:00
Christian Poveda
c1d1f1b694
fix clippy lints
2022-10-18 12:05:27 -05:00
Emilio Cobos Álvarez
66388deae3
Specify readme properly.
2022-10-16 21:56:05 +02:00
Emilio Cobos Álvarez
4f9b970f95
v0.61.0
2022-10-16 21:44:20 +02:00
Emilio Cobos Álvarez
142f62abdf
ci: clippy fixes.
...
The allowed casts are because c_longlong etc aren't guaranteed to map to
i64 / etc. I believe c_double maps to f64 in all platforms tho.
2022-10-16 21:29:41 +02:00
Emilio Cobos Álvarez
c424e03415
Add a few missing changelog entries.
2022-10-16 21:29:41 +02:00
Emilio Cobos Álvarez
2c01810c3a
Remove no-longer-correct include entry in Cargo.toml.
2022-10-16 21:29:41 +02:00
Emilio Cobos Álvarez
6f6f9fb402
Move the csmith-fuzzing directory to the top level.
2022-10-16 21:29:41 +02:00
Christian Poveda
17dd093130
Handle incomplete external array constants
...
This adds a new special case for constants like:
```c
extern const char some_static_string[];
```
so `bindgen` emits a `static` instead of a `static mut` for them.
2022-10-16 20:23:34 +02:00
Christian Poveda
626797bf6c
Merge pull request #2302 from ferrous-systems/clonable-builder
...
Implement `Clone` for `Builder`
2022-10-12 11:07:37 -05:00
Christian Poveda
d241e9554c
Merge pull request #2299 from ferrous-systems/more-robust-postprocessing
...
Make postprocessing more robust
2022-10-10 09:46:26 -05:00
Christian Poveda
46cd3af9c6
Implement Clone
for Builder
...
This is done by moving all the remaining `Builder` state into
`BindgenOptions` so any internal logic that affects `Builder` state only
runs once the builder is consumed by `Builder::generate`:
- move `input_headers` to `BindgenOptions`.
- move `input_header_contents` to `BindgenOptions`.
- derive `Clone` for `Builder`.
2022-10-07 14:10:24 -05:00
Christian Poveda
c8d569930e
update CHANGELOG.md
( #2298 )
2022-10-07 01:30:25 +02:00
Christian Poveda
4dd91ff6d7
Make postprocessing more robust
...
This is done by merging extern blocks and sorting items in every module
instead of just in the root module.
The tests were changed to use `cxx` namespaces so they effectively check
that items are manipulated correctly in every single module.
2022-10-06 14:52:29 -05:00
Christian Poveda
63bf6433e1
Merge pull request #2228 from justsmth/generated_name_override
...
Generated name override
2022-10-06 12:45:40 -05:00
Justin Smith
c1d8cfb552
Merge branch 'master' into generated_name_override
2022-10-06 13:30:17 -04:00
Emilio Cobos Álvarez
576fd8d424
context: Fix tokenization of C++20 inline namespace. ( #2294 )
...
Fixes #2293
2022-10-05 05:00:28 +02:00
Christian Poveda
73ce4bc9a5
Merge pull request #2284 from ferrous-systems/bindgen-as-workspace
...
Bindgen as a workspace
2022-10-04 20:56:55 -05:00
Christian Poveda
0296f9e86c
split the repo into a workspace
...
remove `clap` dependency 🎉
update the book installation instructions
2022-10-04 20:47:17 -05:00
Christian Poveda
a900f8f863
Merge pull request #2291 from ferrous-systems/fix-clippy-lints
...
Address clippy lints
2022-10-03 14:23:56 -05:00
Christian Poveda
cebdedcc40
address clippy lints
2022-10-03 13:02:17 -05:00
Christian Poveda
15aef5e43b
Merge pull request #2285 from ferrous-systems/clone-options
...
Make `BindgenOptions` clonable
2022-10-03 11:17:18 -05:00
Christian Poveda
17252c73fa
remove reference
2022-10-03 10:01:46 -05:00
Cameron Mulhern
8b69ba05aa
Enables blocklisting of Objective-C methods
2022-10-02 19:40:24 -04:00
Christian Poveda
e68b8c0e2b
Merge pull request #2287 from goffrie/dont-traverse-stdint
...
Don't traverse through special-cased <stdint.h> types.
2022-09-28 21:35:50 -05:00
Geoffry Song
70115a0863
Don't traverse through special-cased <stdint.h> types.
2022-09-28 22:56:27 +00:00
Christian Poveda
b5ec18e374
Merge pull request #2282 from ferrous-systems/sovereign-module-of-syn
...
Move codegen postprocessing to its own module
2022-09-27 14:11:39 -05:00
Christian Poveda
ddb319ce35
split processing
module
2022-09-27 13:43:33 -05:00
Christian Poveda
4cfd06e9e1
make BindgenOptions
clonable
2022-09-26 13:22:15 -05:00