summaryrefslogtreecommitdiff
path: root/src/codegen
AgeCommit message (Collapse)Author
2017-10-02Make functions which take an ItemId generic to take any kind of idNick Fitzgerald
2017-10-02Make `TypeKind::{Alias,TemplateAlias,Array,Pointer,Reference}` use `TypeId`Nick Fitzgerald
This commit makes certain `TypeKind`s that can only reference other types use `TypeId` instead of `ItemId`.
2017-10-02Turn `build_templated_path` into `build_path`Nick Fitzgerald
None of the callers were passing template parameters.
2017-10-02Remove unused parameter to `codegen::utils::type_from_named`Nick Fitzgerald
2017-10-02Introduce the `TypeId` newtype over `ItemId`Nick Fitzgerald
This commit also makes `BindgenContext::resolve_type` take a `TypeId`, and adds unchecked conversions everywhere that we call it. Next, I'm going to go through the code base, replacing these unchecked conversions with checked ones, and tightening up types as I go.
2017-09-25codegen: Avoid generating wrong type for enums with unknown representations.Emilio Cobos Álvarez
2017-09-22Deanonymize fieldsSergey Pepyakin
Clean. Add timer. Clean codegen
2017-09-22Auto merge of #1016 - pepyakin:impl-debug-fixes, r=fitzgenbors-servo
Impl_debug fixes r? @fitzgen
2017-09-22Rename derive_debug → impl_debug.Sergey Pepyakin
2017-09-22Generate base names upon constructon.Sergey Pepyakin
2017-09-19Derive Ord when possibleSergey Pepyakin
2017-09-19Emit derive(PartialOrd)Sergey Pepyakin
2017-09-14Add a `Builder::blacklist_type`Alexey Zabelin
This deprecates `Builder::hide_type`. Related to #984. - [x] Add Builder::blacklist_type, that does the same thing as hide_type - [x] Mark Builder::hide_type as #[deprecated = "Use blacklist_type instead"] - [x] Make hide_type delegate to blacklist_type - [x] Rename the BindgenOptions::hidden_types member to BindgenOptions::blacklisted_types - [x] Rename ir::context::BindgenContext::hidden_by_name to blacklisted_by_name - [x] Rename ir::item::Item::is_hidden to is_blacklisted
2017-09-11Make bindgen generate enums as constants by defaultCldfire
Also simplifies the logic that determines which enum variation gets chosen.
2017-09-07Use the `quote!` macro for `link_name` attributesNick Fitzgerald
The latest `rustfmt` has fixed the formatting bugs we were running into.
2017-09-07Use `quote` instead of `syntex` for Rust code generationNick Fitzgerald
The `syntex` crate is unmaintained. It is slow to build, and additionally it requires that we pre-process `src/codegen/mod.rs` before we build the `bindgen` crate. The `quote` crate provides similar quasi-quoting functionality, is maintained, and builds faster. It doesn't have a typed API or builders, however; it only deals with tokens. Before this commit: ``` $ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 98.75 secs ``` After this commit: ``` $ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 46.26 secs ``` Build time is cut in half! But what about run time? Before this commit: ``` Generated Stylo bindings in: Duration { secs: 3, nanos: 521105668 } ``` After this commit: ``` Generated Stylo bindings in: Duration { secs: 3, nanos: 548797242 } ``` So it appears to be about 20ms slower at generating Stylo bindings, but I suspect this is well within the noise. Finally, this also lets us remove that nasty `mem::transmute` inside `bindgen::ir::BindgenContext::gen` that was used for the old `syntex` context. Now `BindgenContext` doesn't have a lifetime parameter either. This should make it easier to revisit doing our analyses in parallel with `rayon`, since that context was one of the things that made it hard for `BindgenContext` to implement `Sync`. Fixes #925
2017-09-06Auto merge of #950 - fitzgen:no-derive-copy-for-blacklisted-types, r=emiliobors-servo
Derive + blacklisted types * [X] document blacklisting + derive interaction * [X] derive `Copy` * [X] derive `Debug` * [X] `--impl-debug` * [x] derive `Default` * [x] derive `Hash` * [x] derive `PartialEq`
2017-09-06Don't try and debug format blacklisted types when generating `impl Debug` blocksNick Fitzgerald
2017-09-06Check derive_copy optionmchlrhw
2017-08-30Squash commit for --time-phases command line optionJackson O'Donnell
initial timer branch commit added time_phases builder parameter create timers for BindgenContex analyses, codegen time parse added docstrings added fitzgens suggestions add --time-phases to bindgen::Builder::command_line_flags
2017-08-29Auto merge of #936 - jhod0:no_fieldgen_on_opaque, r=fitzgenbors-servo
Avoid generating fields/methods for opaque objects WIP fix for issue #929 With libclang 4, passes all tests on my machine except `dump_preprocessed_input`, but that fails on the master branch as well
2017-08-29removed commented code, added punctuationJackson O'Donnell
2017-08-28no fields or methods created for opaqueJackson O'Donnell
2017-08-24Simplify helpers::blobMalo Jaffré
Thanks @fitzgen for the detailed instructions. Fixes #928.
2017-08-21Can derive EqZhiting Zhu
2017-08-21Rename `TypeKind::Named` to `TypeKind::TypeParam`Anna Liao
Also renames a bunch of other things referring to named types to refer to type parameters. Fixes #915
2017-08-14Can derive PartialEq analysisZhiting Zhu
2017-08-14Fixes compilation warnings with rustc 1.21.0-nightly (13d94d5fa 2017-08-10)Bastian Köcher
2017-08-14Fixes alignment errors with new Rust union typeBastian Köcher
This fix creates a new private field with the required aligned size. This new private field ensures that the union has the required size.
2017-08-13Re-add --rust-target to replace --unstable-rustTravis Finkenauer
Instead of specifying whether or not to use stable, specify the Rust release to support (one of several stable/beta releases or nightly). The `--unstable-rust` option is still accepted and implies nightly. The definitions of `RustTarget` and `RustFeatures` are created with macros. For each test that uses unions, there is a version that uses the latest stable and 1.0. This also fixes the bug where unions were generated with non-Copy fields.
2017-08-10Auto merge of #899 - bkchr:manual_debug_impl, r=fitzgenbors-servo
Implements Debug trait for types which do not support derive Debug For types that do not support derive Debug be implemented automatically by rust, we know can generate implementations of the Debug trait. This code generation is hidden behind the '--force-derive-debug' command-line flag. Should solve: #875 Sorry for the extra noise in lib.rs, codegen/mod.rs etc, that was rustfmt.
2017-08-10Adds ImplDebug trait for creating the Debug trait implementationsBastian Köcher
2017-08-10Implements Debug trait for types which do not support derive DebugBastian Köcher
For types that do not support derive Debug be implemented automatically by rust, we know can generate implementations of the Debug trait. This code generation is hidden behind the '--force-derive-debug' command-line flag.
2017-08-09Can derive Hash analysiszzhu
2017-08-04Revert "Add --rust-target to replace --unstable-rust"Nick Fitzgerald
This reverts commit 0bb7b9f1c4652f63f41eba4064b79c044fd3d955. It turns out our CI stopped running test expectations in an earlier regression (from d73507e; fix incoming) and so this pull request actually introduced a bunch of failures when compiling the test expectations and running their unit tests :(
2017-08-04Add --rust-target to replace --unstable-rustTravis Finkenauer
Instead of specifying whether or not to use stable, specify the Rust release to support (one of several stable/beta releases or nightly). The --unstable-rust option is still accepted and implies nightly. The definitions of `RustTarget` and `RustFeatures` are created with macros. For each test that uses unions, there is a version that uses the latest stable release and stable 1.0.
2017-08-03Can derive copy analysiszzhu
2017-07-27can derive default analysiszzhu
2017-07-27Remove the `CanDeriveDebug::Extra` associated typeNick Fitzgerald
Similar to `HasVtable::Extra`, it is no longer needed.
2017-07-25Merge pull request #853 from fitzgen/rust-lang-nurseryNick Fitzgerald
s/servo/rust-lang-nursery/ \o/
2017-07-25s/servo/rust-lang-nursery/ \o/Nick Fitzgerald
Fixes #852
2017-07-25has vtable analysiszzhu
2017-07-22Remove whitelisted_items as arg to codegen funcsOmar Akkila
2017-07-21ir: Track the codegen-reachable items, and use it instead of ↵Emilio Cobos Álvarez
whitelisted_items() for code generation. This standardizes the behavior change at #834, but without regressions. I've added a few more tests for #833 here.
2017-07-21Auto merge of #829 - servo:disambig, r=emiliobors-servo
Use fully disambiguated name instead of a number for layout tests (fixes #394) These numbers cause tons of churn in the diffs for checked in bindings. r? @fitzgen
2017-07-20Only traverse the IR graph to compute whitelisted items onceNick Fitzgerald
We used to do this traversal all the time, but we can do it the one time, after we finish constructing the IR graph and before we begin computing any of our analyses.
2017-07-20Use fully disambiguated name instead of a number for layout tests (fixes #394)Manish Goregaokar
2017-07-20Only whitelist items which we intend to generate code forNick Fitzgerald
This makes only generating certain kinds of items more robust, since we don't need to keep checking whether codegen is enabled for different kinds of items all over the place, and can do it the once. It should also reduce the number of items we have to consider in our various analyses for which we don't ultimately care about the answer. Fixes #826
2017-07-10codegen: Make comments indentation-aware.Emilio Cobos Álvarez
This commit moves comment processing to a central place (well, two, because of field docs, but that's fine). Also, it makes comments indentation aware, so multiline comments don't appear garbled. Finally, it also fixes an out-of-bounds panic when processing an empty multiline comment.
2017-07-09codegen: Fix some sloppiness in our handling of opaque types.Emilio Cobos Álvarez
Fixes #801