summaryrefslogtreecommitdiff
path: root/src/codegen
AgeCommit message (Collapse)Author
2018-02-14Revert "Bump quote to 0.4"Nick Fitzgerald
This reverts commit 6899c275ee0ab0687ec66c490ddd1a76f8223513. The `proc_macro2` crate depends on rustc internal crates, which means that `bindgen` would need to be run under `rustup`. We can follow https://github.com/rust-lang/rust/issues/47931 to get updates on when this issue might be resolved and we can update `quote` again. Fixes #1248
2018-02-12codegen: Expose variant comments.Emilio Cobos Álvarez
2018-01-29Auto merge of #1241 - emilio:fwd-decl-no-fun, r=fitzgenbors-servo
codegen: Make forward declarations go through the more generic path. Instead of special-casing. This allows to use the normal flags to control what can be or not derived for them. Arguably deriving Copy / Clone is kind of busted for those, but changing this by default broke tests (RefPtr<ForwardDeclaredType> stopped working for example). So I think this is a good compromise. Fixes #1238
2018-01-29Auto merge of #1240 - emilio:virtual-dtor-fix, r=fitzgenbors-servo
ir: Choose the right mangling for destructors on all codepaths. Fixes #1133.
2018-01-29codegen: Make forward declarations go through the more generic path.Emilio Cobos Álvarez
Instead of special-casing. This allows to use the normal flags to control what can be or not derived for them. Arguably deriving Copy / Clone is kind of busted for those, but changing this by default broke tests (RefPtr<ForwardDeclaredType> stopped working for example). So I think this is a good compromise. Fixes #1238
2018-01-29ir: Choose the right mangling for destructors on all codepaths.Emilio Cobos Álvarez
Fixes #1133.
2018-01-29codegen: Make the cyclic typedef name detection catch more cases.Emilio Cobos Álvarez
By looking through typedefs, we also catch more complex cases like the ones that appear on Android's stdlib. Fixes #946
2018-01-23Bump quote to 0.4Bastien Orivel
2018-01-22codegen: Try to reasonably handle enum : bool.Emilio Cobos Álvarez
Just use the repr name we generate, since we generate constants for that. It's not worth trying to guess the actual type to use IMO. Bindings lose a bit of portability I guess, but that's really a lost bet already, so instead of special-casing bool and map constants, let's use a consistent representation everywhere. Fixes #1145
2018-01-19codegen: Don't generate repr(C) for enums.Emilio Cobos Álvarez
That's only undefined for enums with fields. Fixes #1224 See also: https://botbot.me/mozilla/rustc/2018-01-19/?msg=95934948&page=2
2018-01-06codegen: Be consistent about variadic signatures.Emilio Cobos Álvarez
Fixes #1216.
2017-12-29Don't generate symbols for pure virtual functions.Emilio Cobos Álvarez
Fixes #1197.
2017-12-12Always add `repr(C)` to rustified enumsNick Fitzgerald
If we don't, then eddyb's recent layout optimizations will do unexpected things to them. We also need to handle empty `enum`s without variants. When `repr(C)` is on a Rust `enum`, it cannot be empty, so we need to add a dummy.
2017-11-27Properly handle namespaces for enum configuration optionsTamir Duberstein
...by using canonical_path rather than canonical_name. Fixes #1125.
2017-11-23Auto merge of #1158 - glyn:large-bitfield-units, r=emiliobors-servo
Support bitfield allocation units larger than 64 bits Individual bitfields are still limited to at most 64 bits, but this restriction can be weakened when Rust supports `u128`. This implements issue #816. Usage notes: * Since common code is added to each generated binding, a program which uses more than one binding may need to work around the duplication by including each binding in its own module. * The values created by bitfield allocation unit constructors can be assigned directly to the corresponding struct fields with no need for transmutation. Implementation notes: `__BindgenBitfieldUnit` represents a bitfield allocation unit using a `Storage` type accessible as a slice of `u8`. The alignment of the unit is inherited from an `Align` type by virtue of the field: ``` align: [Align; 0], ``` The position of this field in the struct is irrelevant. It is assumed that the alignment of the `Storage` type is no larger than the alignment of the `Align` type, which will be true if the `Storage` type is, for example, an array of `u8`. This assumption is checked in a debug assertion. Although the double underscore (__) prefix is reserved for implementations of C++, there are precedents for this convention elsewhere in bindgen and so the convention is adopted here too. Acknowledgement: Thanks to @fitzgen for an initial implementation of `__BindgenBitfieldUnit` and code to integrate it into bindgen. r? @emilio
2017-11-21Support bitfield allocation units larger than 64 bitsNick Fitzgerald
Individual bitfields are still limited to at most 64 bits, but this restriction can be weakened when Rust supports u128. This implements issue #816. Usage notes: * Since common code is added to each generated binding, a program which uses more than one binding may need to work around the duplication by including each binding in its own module. * The values created by bitfield allocation unit constructors can be assigned directly to the corresponding struct fields with no need for transmutation. Implementation notes: __BindgenBitfieldUnit represents a bitfield allocation unit using a Storage type accessible as a slice of u8. The alignment of the unit is inherited from an Align type by virtue of the field: align: [Align; 0], The position of this field in the struct is irrelevant. The alignment of the Storage type is intended to be no larger than the alignment of the Align type, which will be true if the Storage type is, for example, an array of u8. Although the double underscore (__) prefix is reserved for implementations of C++, there are precedents for this convention elsewhere in bindgen and so the convention is adopted here too. Acknowledgement: Thanks to @fitzgen for an initial implementation of __BindgenBitfieldUnit and code to integrate it into bindgen.
2017-11-18Generate ptr::null rather than zero literalTamir Duberstein
2017-11-13Avoid bitfield getters and setters accessing memory beyond "self"Glyn Normington
This fixes https://github.com/rust-lang-nursery/rust-bindgen/issues/954.
2017-11-02Detect `#pragma pack(...)` and make `pack(n)` where `n > 1` opaqueNick Fitzgerald
This is a bandaid for #537. It does *not* fix the underlying issue, which requires `#[repr(packed = "N")]` support in Rust. However, it does make sure that we don't generate type definitions with the wrong layout, or fail our generated layout tests.
2017-11-01"Alignment of field" -> "Offset of field"Nick Fitzgerald
It isn't checking alignment at all; it's checking offsets.
2017-11-01Avoid divide-by-zero when checking if a field will merge with bitfieldsNick Fitzgerald
2017-10-30Auto merge of #1119 - pepyakin:derive-partialeq-partialord-refactoring, r=emiliobors-servo
Simple refactoring of derive_partialeq_or_partialord Just simple refactoring with some tricks from https://github.com/rust-lang-nursery/rust-bindgen/pull/1102 r? @fitzgen
2017-10-30Refactor derive_partialeq_or_partialord.Sergey Pepyakin
2017-10-30Need mangle name of fields in struct for impl debugZhiting Zhu
2017-10-28ir: References have no implicit template parameters.Emilio Cobos Álvarez
Fixes #1113.
2017-10-25Compute sizedness with a fixed-point analysisNick Fitzgerald
This fixes a couple bugs where we weren't properly adding an `_address` byte. It also helps pave the way for computing implicit fields (such as padding, `_address`, vtable pointers, etc) in its own pass, before codegen. Fixes #768
2017-10-24Auto merge of #1085 - pepyakin:builtin-clone-impls, r=fitzgenbors-servo
Derive `Clone` along with `Copy` on Rust 1.21 Fixes #934 r? @fitzgen or @emilio
2017-10-24Derive `Clone` along with `Copy` on latest stable.Sergey Pepyakin
2017-10-24Auto merge of #1091 - jrmuizel:linkage, r=emiliobors-servo
Store function linkage in the ir This lets us capture 'static inline' functions in the ir and filter them later down the pipeline. This is the first step on the way to handling these functions better.
2017-10-24Store function linkage in the irJeff Muizelaar
This lets us capture 'static inline' functions in the ir and filter them later down the pipeline. This is the first step on the way to handling these functions better.
2017-10-23Remove `CompInfo::needs_explicit_vtable` and use `HasVtable::has_vtable_ptr` ↵Nick Fitzgerald
instead
2017-10-13Handle unsigned integer constants greater than u32::MAX in codegenNick Fitzgerald
We were not checking signed-ness and emitting the appropriate types. Fixes #1040
2017-10-12Auto merge of #1079 - fitzgen:move-self-into-gen, r=pepyakinbors-servo
Move `self` into `ir::BindgenContext::gen` Small clean up. See each commit for details. r? @pepyakin
2017-10-12Make `ir::BindgenContext::gen` take ownership of `self`Nick Fitzgerald
`bindgen` follows a pipeline architecture, and we only ever generate bindings once. By taking ownership of `self`, we can enforce this. We can also remove checks inside `gen` for whether we have resolved type refs or not, since we now know that we haven't because it is guaranteed to only be called the one time.
2017-10-12Rename `bitfield` to `bitfield_width`Nick Fitzgerald
Its more clear what the methods/fields are returning/storing when we add "width" to the name.
2017-10-11Handle explicit align=1.Sergey Pepyakin
2017-10-11Refactor requires_explicit_alignSergey Pepyakin
2017-10-10Auto merge of #1071 - pepyakin:emit-hex-bitfield-masks, r=fitzgenbors-servo
Emit hex bitfield masks r? @fitzgen
2017-10-10Emit hex bitfield masksSergey Pepyakin
2017-10-10Auto merge of #1065 - liranringel:thiscall, r=fitzgenbors-servo
Add support for the thiscall ABI Fixes https://github.com/rust-lang-nursery/rust-bindgen/issues/541 The thiscall ABI is experimental, so in order to use it nightly is required and also the following statement: `#![feature(abi_thiscall)]` That's a problem because the `tests_expectations` crate (in the tests folder) tries to compile it (and stable is required).
2017-10-09Auto merge of #1066 - pepyakin:bitfields-in-unions, r=fitzgenbors-servo
Bitfields in unions Fixes #744 I think it is WIP for the moment as I didn't run tests locally.
2017-10-10Add support for the thiscall ABILiran Ringel
2017-10-09Fix bitfields in bindgen unionsSergey Pepyakin
2017-10-07Tell LLVM to not mangle names if they're already mangled through link_name ↵Liran Ringel
attribute
2017-10-05Use bitfield getter_name in impl_debug.Sergey Pepyakin
Also make impl_partialeq test to also cover impl_debug case.
2017-10-05Use bitfield getter_name in impl_partialeqSergey Pepyakin
2017-10-05Eagerly generate bitfield accessor namesSergey Pepyakin
Also clean a bit.
2017-10-04Remove early anonymous bitfield filtering and consolidate name methodOliver Geller
2017-10-03Assert we only gen partialeq for non rust unionsSergey Pepyakin
2017-10-03Derive partialeq "manually" when possibleSergey Pepyakin
Remove derive-partialeq-template-inst test. Add comments. Don't implement PartialEq for incomplete arrays Handle opaque bases and template instantiations Extract constrain_type. Extract `is whitelisted?` check Add failing partialeq-anonfield join for comps Fix: return insert if not whitelisted Delegate TypeRefs and alias to constrain_join. Delegate Template instantiations to constrain_join Add derive-partialeq-pointer.hpp test Update comment. Fix layout alignment larger that array limit Add missing test for derive-partialeq-anonfield.rs Clean Clean Fix typo in opaque-template-inst-member test Remove redudant stmt Add comment on can_supersede. Format impl_partialeq and leave a comment Extract requires_storage into it's own function. Clean