summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-04-04ir: Add a note about cpp_demangle.Emilio Cobos Álvarez
2017-04-04tests: Add negative tests for constructor/destructor generation behavior.Emilio Cobos Álvarez
2017-04-04codegen: Simplify method implementations.Emilio Cobos Álvarez
2017-04-04codegen: Add integration tests for destructors.Emilio Cobos Álvarez
2017-04-04codegen: Rename the destructor methods to "destruct".Emilio Cobos Álvarez
2017-04-04options: Allow configuring destructors via CLI.Emilio Cobos Álvarez
2017-04-04Refactor a bit and do not generate virtual destructors.Emilio Cobos Álvarez
2017-04-04Add codegen for destructors.Nikhil Shagrithaya
2017-04-04ir: Force the D1 destructor symbol even in older libclang versions.Emilio Cobos Álvarez
2017-04-03options: Allow configuring the generation of constructors.Emilio Cobos Álvarez
2017-03-31Auto merge of #604 - tsliang:master, r=fitzgenbors-servo
This should resolve #571. As discussed with @fitzgen I have moved the builtin-filtering out of `ast_dump` itself; this logic now happens at the point of call in `src/lib.rs`
2017-03-31#571: Allow ast_dump to print builtins; filter builtins locallyTai Sassen-Liang
2017-03-31Merge pull request #602 from emilio/clang-5Emilio Cobos Álvarez
clang: Fix most of the clang 5.0 regressions in our tests.
2017-03-30 clang: Fix most of the clang 5.0 regressions in our tests.Emilio Cobos Álvarez
2017-03-27Auto merge of #601 - luser:string-input, r=emiliobors-servo
Add a `Builder::header_contents` method to allow passing source code as a string to a Builder Currently the Builder API requires input as header files on disk. This allows passing C source directly to clang using the existing UnsavedFile struct. I'm going to take a shot at implementing a webapp that lets users paste in C source and get the bindgen output. It would make life easier if I didn't have to write the source out to a temp file. This patch allows passing the source in as a `&str`. I wasn't quite sure where to put the new test, but it seems to work in tests.rs.
2017-03-27Add a `Builder::header_contents` method to allow passing source code as a ↵Ted Mielczarek
string to a Builder Currently the Builder API requires input as header files on disk. This allows passing C source directly to clang using the existing UnsavedFile struct.
2017-03-27Auto merge of #600 - emilio:fwd-enum, r=upsuperbors-servo
ir: Prefer the enum definition instead of the declaration when looking for variants. Fixes #599
2017-03-27tests: Disable rustfmt tests, for now.Emilio Cobos Álvarez
2017-03-23ir: Prefer the enum definition instead of the declaration when looking for ↵Emilio Cobos Álvarez
variants.
2017-03-21Auto merge of #597 - servo:void-vtable, r=fitzgen,emiliobors-servo
Make vtables non-zero-size to fix a rustc warning. ``` warning: found non-foreign-function-safe member in struct marked #[repr(C)]: found zero-size struct in foreign module, consider adding a member to this struct ``` Emilio said on IRC: > the empty vtable means that we don't care of figuring out the proper vtable layout, so we create an empty struct Sounds like all that matters is to have a pointer, we don’t look at the data behind it. Using `c_void` seems appropriate, then.
2017-03-21Make vtables non-zero-size to fix a rustc warning.Simon Sapin
``` warning: found non-foreign-function-safe member in struct marked #[repr(C)]: found zero-size struct in foreign module, consider adding a member to this struct ```
2017-03-21Do not derive Default on vtable typesSimon Sapin
https://github.com/servo/rust-bindgen/pull/597#issuecomment-288006557
2017-03-20Auto merge of #595 - emilio:force-inline, r=SimonSapinbors-servo
options: Allow force-generating inline functions.
2017-03-20options: Allow force-generating inline functions.Emilio Cobos Álvarez
2017-03-18Auto merge of #591 - ambaxter:macro_exp, r=emiliobors-servo
How would you suggest testing this?
2017-03-17Renamed chooser to visitor and added function for parsed macro analysis.Adam Baxter
Added tests and fixed missed function rename. Fixed nits Renamed visitor to callbacks. Renamed visitor to callbacks. Renamed visitor to callbacks. Fixed text.
2017-03-16Auto merge of #589 - fitzgen:conflicting-methods-and-bitfield-accessors, ↵bors-servo
r=emilio Resolve namespace clashes between methods and generated bitfield accessors This commit makes bitfields' accessor codegen detect conflicting method names and generate alternative, non-conflicting names instead. Yes, I really hit this in SpiderMonkey... r? @emilio
2017-03-16Resolve namespace clashes between methods and generated bitfield accessorsNick Fitzgerald
This commit makes bitfields' accessor codegen detect conflicting method names and generate alternative, non-conflicting names instead.
2017-03-16Auto merge of #588 - fitzgen:more-clang-version-testing, r=emiliobors-servo
Run tests with more versions of libclang First, update our existing 3.8.X and 3.9.X libclang testing versions to their latest point releases. Second, add testing on the latest 3.7.X release and the latest 4.0.X release. r? @emilio
2017-03-16Run tests with more versions of libclangNick Fitzgerald
First, update our existing 3.8.X and 3.9.X libclang testing versions to their latest point releases. Second, add testing on the latest 3.7.X release and the latest 4.0.X release.
2017-03-15Auto merge of #587 - fitzgen:little-helper-stuff, r=emiliobors-servo
Little helper stuff A couple things that I've found helpful for iterative debugging. r? @emilio
2017-03-15Add edge labels to our graphviz outputNick Fitzgerald
This adds the `EdgeKind` as a label to edges in the graphviz IR dump output. This is useful for understanding why something is referenced by another thing.
2017-03-15Add a script to test bindings generation and layout for one header at a timeNick Fitzgerald
2017-03-15Auto merge of #581 - ↵bors-servo
fitzgen:issue-573-even-more-spidermonkey-layout-test-failures, r=emilio Refactor fallibility of conversions from IR to Rust types The old `ToRustTy` and `ItemToRustTy` conversion traits were problematic in that they assumed infallibity. That assumption is problematic because we are often dealing with C++ constructs for which Rust has no equivalent *and* we don't have a usable layout from which to generate an opaque blob in its stead. But, a usable layout is often "up the stack" if only we had a way to get up there. For example, Rust does not currently have an equivalent of const value template parameters, and libclang will not give us a layout for template definitions with const value template parameters. However, libclang will give us the layout for an instantiation of such a template definition. First, this commit separates the concepts of generating an equivalent Rust type from generating an opaque blob of the same size and alignment as an IR thing. This consolidates and DRYs up a *ton* of code involved in falling back to an opaque blob (and doing our best to get a `Layout` for the blob) when we can't generate an equivalent Rust type for some IR thing. Second, it separates fallible and infallible conversions, and provides a nice little framework for when to choose which. This gives us one single place where we do this whole dance: if could not generate equivalent Rust type: if we have a layout: return opaque blob based on layout else: return opaque blob based on a wish and a prayer The `ToRustTy` trait is replaced by the `TryToOpaque`, `ToOpaque`, `TryToRustTyOrOpaque`, and `ToRustTyOrOpaque` traits. The `ItemToRustTy` helper was just a way to avoid `ToRustTy`'s `Self::Extra` parameter when it was not needed, and is simply removed without a replacement. We suck it up and pass `&()` at call sites now. We *could* introduce `ItemTryToOpaque`, `ItemToOpaque`, etc... traits, but the cost of the added boiler plate would outweigh the benefits of not passing `&()` at call sites, IMHO. In addition to being a nice code cleanup, this also fixes #573. r? @emilio
2017-03-15Refactor fallibility of conversions from IR to Rust typesNick Fitzgerald
The old ToRustTy and ItemToRustTy conversion traits were problematic in that they assumed infallibity. That assumption is problematic because we are often dealing with C++ constructs for which Rust has no equivalent *and* we don't have a usable layout from which to generate an opaque blob in its stead. But, a usable layout is often "up the stack" if only we had a way to get up there. For example, Rust does not currently have an equivalent of const value template parameters, and libclang will not give us a layout for template definitions with const value template parameters. However, libclang will give us the layout for an instantiation of such a template definition. First, this commit separates the concepts of generating an equivalent Rust type from generating an opaque blob of the same size and alignment as an IR thing. This consolidates and DRYs up a *ton* of code involved in falling back to an opaque blob (and doing our best to get a Layout for the blob) when we can't generate an equivalent Rust type for some IR thing. Second, it separates fallible and infallible conversions, and provides a nice little framework for when to choose which. This gives us one single place where we do this whole dance: if could not generate equivalent Rust type: if we have a layout: return opaque blob based on layout else: return opaque blob based on a wish and a prayer The ToRustTy trait is replaced by the TryToOpaque, ToOpaque, TryToRustTyOrOpaque, and ToRustTyOrOpaque traits. The ItemToRustTy helper was just a way to avoid ToRustTy's Self::Extra parameter when it was not needed, and is simply removed without a replacement. We suck it up and pass `&()` at call sites now. We *could* introduce ItemTryToOpaque, ItemToOpaque, etc... traits, but the cost of the added boiler plate would outweigh the benefits of not passing `&()` at call sites, IMHO. In addition to being a nice code cleanup, this also fixes #573.
2017-03-15Auto merge of #583 - emilio:macro-inf, r=fitzgenbors-servo
ir: Ignore non-finite macro constants from macros. Fixes #582.
2017-03-15ir: Generate non-finite floating point constants properly.Emilio Cobos Álvarez
2017-03-13Auto merge of #579 - emilio:mangling, r=fitzgenbors-servo
options: Honor distrust-clang-mangling.
2017-03-13Auto merge of #575 - ↵bors-servo
fitzgen:issue-574-anonymous-template-parameters-and-assertion-failure, r=fitzgen Allow anonymous template types We have various assertions that the only way that some template parameter related methods will return `None` is if the template definition is marked opaque. These assertions fail in the presence of test cases with unnamed template types, because we never save an IR item for the template type, and subsequently think that the template definition has no template parameters. The assertions are in fact sound and correct, so it doesn't make sense to remove them. Instead it is more correct to save IR items for the anonymous template types and simply let the template usage analysis prevent them from getting codegen'd. Fixes #574 r? @emilio
2017-03-12options: Honor distrust-clang-mangling.Emilio Cobos Álvarez
2017-03-10Properly align function argumentsNick Fitzgerald
Not sure why rustfmt hasn't caught this before...
2017-03-10Allow anonymous template typesNick Fitzgerald
We have various assertions that the only way that some template parameter related methods will return `None` is if the template definition is marked opaque. These assertions fail in the presence of test cases with unnamed template types, because we never save an IR item for the template type, and subsequently think that the template definition has no template parameters. The assertions are in fact sound and correct, so it doesn't make sense to remove them. Instead it is more correct to save IR items for the anonymous template types and simply let the template usage analysis prevent them from getting codegen'd. Fixes #574
2017-03-09Auto merge of #565 - framlog:master, r=fitzgenbors-servo
automatically allow non rust naming conventions + related issue: #562 I just added those attributes at the root mod. And I'm not sure whether it should be better if we could set this setting in `build.rs`.
2017-03-09Auto merge of #572 - fitzgen:sm-layout-test-failures, r=emiliobors-servo
Generate better opaque blobs in the face of non-type parameters When instantiating templates whose definitions have non-type generic parameters, prefer the layout of the instantiation type to the garbage we get from the definition's layout. In general, an instantiation's layout will always be a better choice than the definition's layout, regardless of non-type parameters. Fixes #569 r? @emilio
2017-03-09Replace if let / else return with matchNick Fitzgerald
It reads a little bit better this way, but is exactly equivalent.
2017-03-09Add a comment documenting the hacky test of `()` from ToRustTyNick Fitzgerald
2017-03-09Generate better opaque blobs in the face of non-type parametersNick Fitzgerald
When instantiating templates whose definitions have non-type generic parameters, prefer the layout of the instantiation type to the garbage we get from the definition's layout. In general, an instantiation's layout will always be a better choice than the definition's layout, regardless of non-type parameters. Fixes #569
2017-03-09Simplify control flow in TemplateInstantiation's ToRustTyNick Fitzgerald
If we hit a case where we generate an opaque blob instead of an instantiation of a generic, then we won't ever be attaching generic parameters, and can bail out of the function early.
2017-03-09Implement ToRustTy for TemplateInstantiationNick Fitzgerald
This pulls existing code out of Type's ToRustTy implementation and into an implementation of ToRustTy for TemplateInstantiation. Purely code motion.
2017-03-09Auto merge of #567 - fitzgen:bitfield-accessors, r=emiliobors-servo
Reintroduce bitfield accessors This commit reintroduces accessor methods for bitfields in the generated bindings. Fixes #519 r? @emilio