summaryrefslogtreecommitdiff
path: root/src/codegen
AgeCommit message (Collapse)Author
2022-10-04split the repo into a workspaceChristian Poveda
remove `clap` dependency :tada: update the book installation instructions
2022-10-03address clippy lintsChristian Poveda
2022-10-02Enables blocklisting of Objective-C methodsCameron Mulhern
2022-09-27split `processing` moduleChristian Poveda
2022-09-26s/static/constChristian Poveda
2022-09-23Clean-up postprocessing to use less macro magic.Emilio Cobos Álvarez
2022-09-23move codegen postprocessing to its own moduleChristian Poveda
2022-09-23Map size_t to usize by default and check compatibility (fixes #1901, #1903)Geoffrey Thomas
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-22use `#[feature(core_ffi_c)]` when availableChristian Poveda
2022-09-22codegen: Implement manuallydrop fields better.Emilio Cobos Álvarez
This doesn't change behavior but makes the code make more sense.
2022-09-23Option to wrap union members in ManuallyDrop (#2185)Poliorcetics
2022-09-22check for noreturn attributeChristian Poveda
2022-09-18fix `--newtype-global-enum` optionChristian Poveda
2022-09-11add `--newtype-global-enum` optionChristian Poveda
2022-09-01address clippy lintsChristian Poveda
2022-08-18store warnings and emit them laterChristian Poveda
2022-07-16Add revision suggestion for MSRV >= 1.59.0onalante-msft
2022-07-16Extract pointer once for all alignment testsonalante-msft
2022-07-16Only insert uninit_decl if check_field_offset is non-emptyonalante-msft
2022-07-16rustfmtonalante-msft
2022-07-16Remove functions, use same uninit for all field testsonalante-msft
2022-07-16Place field alignment test functions before statementsonalante-msft
Clears clippy::items_after_statements warning for tests.
2022-06-06codegen: tests: Put each individual field test in a function.Emilio Cobos Álvarez
So that rustc doesn't take too much stack space without optimizations. Fixes #2218
2022-06-05Fix some clippy warningsDarren Kulp
cargo clippy --fix --tests cargo +nightly fmt
2022-06-05ir: Centralize must_use checks and simplify codegen.Emilio Cobos Álvarez
2022-06-05Look for `must_use` on typdefs in function returnIan Chamberlain
Closes #2206
2022-05-17Fix "dereferencing a null pointer" in C layout testsGavin Li
Instead of dereferencing a null pointer, create a MaybeUninit from which we can extract well-defined addresses.
2022-05-08Derive from any other trait only when deriving from CopyMichal Rostecki
It's impossible to #[derive] from any other trait when not deriving from Copy when using the newest Rust nightly. Any attempt to do that results in the following error: error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133) Fixes: #2083 Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2022-04-19Use common type alias for anonymous enums in consts modeAlan Wu
Previously, anonymous enums generated a type alias but did not use it. For example the following: ```C enum { ZERO, ONE = 4999, }; ``` Generated this: ```Rust /* automatically generated by rust-bindgen 0.59.2 */ pub const ZERO: ::std::os::raw::c_uint = 0; pub const ONE: ::std::os::raw::c_uint = 4999; pub type _bindgen_ty_1 = ::std::os::raw::c_uint; ``` For use cases where humans look at bindgen's Rust output this was a little strange since it's a deviation from how the Rust output for named enums is organized, where all constants share the same type using the type alias. The unused type alias also triggered the dead_code lint. Change to use the generated type alias.
2022-03-15codegen: Fix minor clippy warning.Emilio Cobos Álvarez
2022-03-15add attributes to dynamic functionsEmil Gardström
this includes comments and must_use annotations
2022-03-15codegen: Simplify abi support condition.Emilio Cobos Álvarez
2022-03-15Added support for `vectorcall` ABIDavid Cole
2022-03-15Fix macOS test expectationsSebastian Imlay
* Updated tests/expectations/Cargo.toml to use 2018 rust. * Added Debug and Copy to objective-c structs. * Fixed lifetimes in objective-c trait templates. * Fixed imports for objective-c expectations tests.
2022-02-18codegen: Use raw pointers rather than references in vtable functions.Emilio Cobos Álvarez
Closes #2163
2022-02-18Put vtable generation behind a flag for now.Emilio Cobos Álvarez
2022-02-18Allow fully-qualified derivesJake Merdich
Adding a custom derive like "serde::Deserialize" results in a panic complaining that it is not a valid Ident. Derive params are not identifiers, so treat it as a token stream instead.
2022-02-18Fix an erroneous +x bit on a source code file.Adrian Taylor
2022-01-29Mark all vtable functions as `unsafe extern "C"`Justin Moore
2022-01-29On second thought, don't generate virtual destructorsDr. Chat
2022-01-29Mark all vtable functions as `pub`Dr. Chat
2022-01-29Account for virtual destructorsDr. Chat
2022-01-29Pass the vtable's base class as the first parameterDr. Chat
2022-01-29Extremely basic Vtable generationDr. Chat
2021-12-29codegen: Don't automatically derive Debug and Copy for non-rust enums.Emilio Cobos Álvarez
Fixes #2143
2021-11-26Drop 'static for pub const strings for rustc>1.17Alberto Planas
Constant and static declaration have a 'static live time by default, that is already elided since 1.17. Clippy complains on this kind of strings that are present in the generated code. This patch remove the 'static live time for those strings when rustc > 1.17 via a new added RustFeature. Fix #1612 Signed-off-by: Alberto Planas <aplanas@suse.com>
2021-11-26allow custom derives on enumsEric Seppanen
Custom derives are just as useful on enums as they are on structs; not supporting this was an oversight. Adds a test that will fail to compile if the custom derive doesn't work on enums. This test fails without the codegen fix.
2021-10-27Don't generate 2^64 byte padding fields on unionsTheodore Dubois
The --explicit-padding flag would make bindgen try to add tail padding to rust unions, by adding up the size of all the union fields and subtracting from the size of the union as given by clang. The total size of a union's fields is always larger than the union, so the subtraction underflowed and bindgen produced padding fields larger than addressable RAM.
2021-10-27Fix warningsMikuroXina
2021-08-24Use annotations on enumerations: This enables users to add additional ↵Christian Vetter
derives, or prevent deriving traits Fixes #2076