Commit Graph

1748 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
96304f90a4
Breaking version bump. 2017-07-10 23:16:59 +02:00
Emilio Cobos Álvarez
3738f97598
codegen: Make comments indentation-aware.
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-10 23:16:59 +02:00
bors-servo
ffc529d11f Auto merge of #802 - emilio:opaque, r=fitzgen
codegen: Fix some sloppiness in our handling of opaque types.

Fixes #801
2017-07-10 09:11:07 -07:00
Emilio Cobos Álvarez
cb0ef01b16
codegen: Fix some sloppiness in our handling of opaque types.
Fixes #801
2017-07-09 16:02:44 +02:00
bors-servo
f19e576961 Auto merge of #791 - dylanmckay:preprocess-doc-comments, r=emilio
Intelligently convert C/C++ comments to Rust

With this change, we can correctly parse C++ block comments.

```cpp
/**
 * Does a thing
 *
 * More documentation. This test does something
 * useful.
 */
```

into

```rust
/// Does a thing
///
/// More documentation. This test does something
/// useful.
```

Fixes servo/rust-bindgen#426.
2017-07-08 09:30:10 -07:00
Dylan McKay
239a0154cd Intelligently convert C/C++ comments to Rust
With this change, we can correctly parse C++ block comments.

```
/**
 * Does a thing
 *
 * More documentation. This test does something
 * useful.
 */
```

into

```
/// Does a thing
///
/// More documentation. This test does something
/// useful.
```

Fixes servo/rust-bindgen#426.
2017-07-08 11:38:23 +12:00
bors-servo
71f2410a54 Auto merge of #796 - tz70s:master, r=fitzgen
Automatically detect libclang version when testing

Automatically detect libclang version when testing and use approppriate
expectation files.

Ref to issue #794.
2017-07-07 13:19:57 -07:00
tz70s
12e06f421d Automatically detect libclang version when testing
Automatically detect libclang version when testing and use approppriate
expectation files. Ref issue #794.
2017-07-08 04:10:20 +08:00
bors-servo
c93b1dede5 Auto merge of #797 - photoszzt:sep_analysis, r=fitzgen
Separate the analysis framework in a different file.

r? @fitzgen #765
2017-07-07 12:18:36 -07:00
zzhu
d3bb41a258 Separate the analysis framework in a different file. 2017-07-07 11:34:28 -07:00
bors-servo
8d328d500f Auto merge of #795 - fitzgen:no-system-includes, r=emilio
No system includes in test headers

See each commit message.

Disallowing *system* includes and not *all* includes because we have one local include in `extern.hpp`, and local includes will at least be consistent/reproducible.

r? @emilio
2017-07-07 09:04:20 -07:00
Nick Fitzgerald
706c987b69 Run the ./ci/no-includes.sh test from cargo test
Convenience to help developers catch this earlier, rather than only after
pushing a pull request.
2017-07-06 10:19:32 -07:00
Nick Fitzgerald
945c66a764 Disallow system header file includes in our test suite
There is no guarantee that the system running the tests has the header file, let
alone the same version of it that you have. Any test with such an include
directive won't reliably produce the consistent bindings across systems.
2017-07-06 10:03:08 -07:00
bors-servo
e794cd4ae7 Auto merge of #792 - emilio:inline-ns, r=fitzgen
ir: Properly skip inline namespaces when building names.

Fixes #789
2017-07-06 09:12:02 -07:00
Emilio Cobos Álvarez
e9381670d6
ir: Properly skip inline namespaces when building names.
Fixes #789
2017-07-06 11:20:42 +02:00
bors-servo
3bb248ba24 Auto merge of #790 - servo:fitzgen-patch-1, r=emilio
Minimal test cases don't have `#include`s

The inclusion of an `#include` means that the test case

* is not minimal, and
* is harder to reproduce the bug with, since not everyone has the same headers (or versions of headers) on their system.

r? @emilio
2017-07-05 23:32:07 -07:00
Nick Fitzgerald
1f323cf979 Minimal test cases don't have #includes
The inclusion of an `#include` means that the test case

* is not minimal, and
* is harder to reproduce the bug with, since not everyone has the same headers (or versions of headers) on their system.
2017-07-05 15:00:07 -07:00
bors-servo
78e7546d3b Auto merge of #783 - emilio:bump, r=fitzgen
Minor version bump to grab clang-sys bump.
2017-07-05 12:12:12 -07:00
bors-servo
607b5bd5cd Auto merge of #786 - emilio:mdbook-ci, r=fitzgen
Pin the mdbook version for CI.

Fixes #779.
2017-07-05 11:25:54 -07:00
bors-servo
8f756be1ac Auto merge of #787 - SirVer:00_fix_repetition_operation, r=emilio
Remove Type::detect_has_vtable_cycle.

After some discussion in #765 we do not think anymore that this can ever be true.
2017-07-05 10:41:03 -07:00
Holger Rapp
672b740665 Remove Type::detect_has_vtable_cycle.
After some discussion in #765 we do not think anymore this it can ever
be true.
2017-07-04 22:14:11 +02:00
Emilio Cobos Álvarez
9b4bd6bff7
Pin the mdbook version for CI.
Fixes #779.
2017-07-04 18:29:39 +02:00
Emilio Cobos Álvarez
1bf0b8a40b
Minor version bump to grab clang-sys bump. 2017-07-04 14:34:15 +02:00
bors-servo
d0df1b9700 Auto merge of #781 - shinglyu:linux32, r=emilio
Passing additional clang arguments for Linux 32 cross compiling

This is for https://bugzilla.mozilla.org/show_bug.cgi?id=1366050

But it has to wait for https://github.com/KyleMayes/clang-sys/pull/57 to land and version number bumped.

(I'm making up the new version numbers for now.)

r? @emilio
2017-07-04 03:40:40 -07:00
Shing Lyu
ee478a123e Passing additional clang arguments for Linux 32 cross compiling 2017-07-04 10:09:53 +08:00
bors-servo
1cbb5d39d2 Auto merge of #782 - SirVer:00_fix_repetition_operation, r=fitzgen
Fix tests/test-one.sh.

On Mac OS where egrep is != GNU grep, the script fails with

~~~
egrep: repetition-operator operand invalid
ERROR: no files found with pattern "virtual_inheritance"
~~~~

The `$pattern` is supposed to be a substring in the test name to run.
The leading and trailing stars are wrong, since egrep takes a regular expression, not a glob.
2017-06-30 15:46:21 -07:00
Holger Rapp
5b21f87c3d Fix tests/test-one.sh.
On Mac OS where egrep is != GNU grep, the script fails with

~~~
egrep: repetition-operator operand invalid
ERROR: no files found with pattern "virtual_inheritance"
~~~~

The `$pattern` is supposed to be a substring in the test name to run.
The leading and trailing stars are wrong, since egrep takes a
regular expression, not a glob.
2017-06-30 21:56:32 +02:00
bors-servo
691834d226 Auto merge of #780 - rillian:llvm4, r=emilio
Drop llvm@3.9 versioning for homebrew.

Homebrew now defaults to llvm 4.0.x so there's no need to specify a specific version to get compatibility, unless we specifically want people using 3.9.
2017-06-29 13:39:38 -07:00
Ralph Giles
f13cd7e559 Drop llvm@3.9 versioning for homebrew.
Homebrew now defaults to llvm 4.0.x so there's no need to
specify a specific version to get compatibility.
2017-06-29 13:27:31 -07:00
bors-servo
3106b30bb3 Auto merge of #776 - snipsco:fix/ios-mangling, r=emilio
Fix iOS mangling

Hi,
We had a regression on a project that target iOS while upgrading bindgen from `0.25.3` to `0.25.4`.

After a long investigation it appeared that iOS need also a mangling hack. I managed to make a patch and successfully test it.

Thanks a lot for all your work.
Cheers
2017-06-23 10:44:18 -07:00
Kevin Lefevre
8885365f9f Add mangling hack for ios 2017-06-23 19:07:46 +02:00
bors-servo
313d7920a0 Auto merge of #773 - fitzgen:allow-making-particular-instantiations-opaque, r=emilio
Allow marking specific template instantiations as opaque

If a template has a specialization that bindgen doesn't understand, it can be
helpful to mark it as opaque and continue making forward progress in the
meantime. This is something we need in the SpiderMonkey bindings.

r? @emilio
2017-06-22 09:38:25 -07:00
Nick Fitzgerald
2000177d0b Minor version bump to 0.26.2 2017-06-22 09:37:19 -07:00
Nick Fitzgerald
d9ede21848 Allow marking specific template instantiations as opaque
If a template has a specialization that bindgen doesn't understand, it can be
helpful to mark it as opaque and continue making forward progress in the
meantime. This is something we need in the SpiderMonkey bindings.
2017-06-22 09:36:06 -07:00
bors-servo
480c2d1971 Auto merge of #741 - tmfink:feature-699-constified-enum-module, r=emilio
Feature 699 constified enum module

This is a work in progress for issue #699 that adds the `--constified-enum-module` option to bindgen.

@emilio, could you give me some guidance on fixing the uses of the enum variant types? In the example below, `foo` should be replaced with `foo::Type`. I'm not sure of the proper way to rename `Item`s after the structures have been defined. My initial thought was to redefine the `CodeGenerator` trait to take a mutable reference to `item`, but that will not work because of the borrow checker. Thoughts?

Todo:
- [x] put constified enum variants in a `mod`
- [x] ensure references to constified enum `foo` are changed to `foo::Type`
- [x] handle `typedef` enums

-----

Given the input header `tests/headers/constify-module-enums.h`:
~~~c
// bindgen-flags: --constified-enum-module foo

enum foo {
  THIS,
  SHOULD_BE,
  A_CONSTANT,
};

struct bar {
  enum foo this_should_work;
};
~~~

`$ cargo run -- tests/headers/constify-module-enums.h --constified-enum-module foo --no-layout-tests` will output:
~~~rust
/* automatically generated by rust-bindgen */

pub mod foo {
    pub type Type = ::std::os::raw::c_uint;
    pub const THIS: Type = 0;
    pub const SHOULD_BE: Type = 1;
    pub const A_CONSTANT: Type = 2;
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct bar {
    pub this_should_work: foo,
}
impl Clone for bar {
    fn clone(&self) -> Self { *self }
}
~~~
2017-06-21 05:03:08 -07:00
Travis Finkenauer
814d28e0f2 Simplify is_constified_enum_module
Used suggested code from @emilio and also added a test for an alias to
an anonymous enum.
2017-06-20 22:05:34 -07:00
bors-servo
232a21ebc4 Auto merge of #770 - fitzgen:issue-769-bad-instantiation-test, r=emilio
Ensure that every item is in some module's children list

Previously, if an item's parent was not a module (eg a nested class definition whose parent it the outer class definition) and the parent was not whitelisted but the item was transitively whitelisted, then we could generate uses of the item without emitting any definition for it. This could happen because we were relying on the outer type calling for code generation on its inner types, but that relies on us doing code generation for the outer type, which won't happen if the outer type is not whitelisted.

This commit avoids this gotcha by ensuring that all items end up in a module's children list, and so will be code generated even if their parent is not whitelisted.

This does have the downside of changing the relative order of some of the emitted code, and so this has a big diff (as will the next bindgen update for downstream dependencies) but I actually think the newer order makes more sense, for what that is worth.

Fixes #769

r? @emilio
2017-06-20 16:49:11 -07:00
Nick Fitzgerald
52305657b6 Add a comment about template instantiation parentage 2017-06-20 16:36:10 -07:00
Nick Fitzgerald
c736faaa37 Assert that every item is a child of an ancestor module
This commit adds assertions that run when the "testing_only_extra_assertions"
feature is enabled, which make sure that every single item we parse is a child
of some ancestor module.
2017-06-20 15:35:27 -07:00
Nick Fitzgerald
33272cdc36 Add dotted lines from modules to children in IR visualization
There's a lot of these edges so it helps to make them un-bold.
2017-06-20 15:35:27 -07:00
Nick Fitzgerald
979f5aae9a Ensure that every item is in some module's children list
Previously, if an item's parent was not a module (eg a nested class definition
whose parent it the outer class definition) and the parent was not whitelisted
but the item was transitively whitelisted, then we could generate uses of the
item without emitting any definition for it. This could happen because we were
relying on the outer type calling for code generation on its inner types, but
that relies on us doing code generation for the outer type, which won't happen
if the outer type is not whitelisted.

This commit avoids this gotcha by ensuring that all items end up in a module's
children list, and so will be code generated even if their parent is not
whitelisted.

Fixes #769
2017-06-20 15:35:27 -07:00
bors-servo
49526069a0 Auto merge of #772 - emilio:ff, r=fitzgen
codegen: Inline {read,write}_unaligned in order to support rust 1.15.
2017-06-20 14:14:52 -07:00
Emilio Cobos Álvarez
30dc9daa7a
Minor bump. 2017-06-20 23:10:29 +02:00
Emilio Cobos Álvarez
9cd4d6f5b9
codegen: Inline {read,write}_unaligned in order to support rust 1.15.
... Which is what Firefox uses right now.
2017-06-20 23:09:56 +02:00
Nick Fitzgerald
26094eaec3 Allow path separators in test-one.sh
Before this commit, test-one.sh was unusable with tests/headers/template.hpp
because there were too many things with "template.hpp" as a suffix. This allows
us to specify "/template.hpp" to run the test.
2017-06-20 10:36:49 -07:00
bors-servo
a99bbd865e Auto merge of #771 - emilio:bump, r=nox
Breaking version bump.
2017-06-20 03:58:00 -07:00
Emilio Cobos Álvarez
8470e221f9
Breaking version bump. 2017-06-20 12:56:36 +02:00
bors-servo
521b7d11b0 Auto merge of #764 - fitzgen:as-named-to-as-template-param, r=emilio
Rename `AsNamed` to `AsTemplateParam`

And also its trait methods `is_named` and `as_named` into `is_template_param`
and `as_template_param` respectively.

These new names better reflect what the trait is about.

r? @emilio
2017-06-20 01:26:56 -07:00
bors-servo
27e2c108ef Auto merge of #763 - rigelk:757-unstable-defaults, r=emilio,fitzgen
switch defaults from generating unstable Rust to generating stable Rust

As said in the issue:
- changing the Builder::no_unstable_rust method to the Builder::unstable_rust method
- changing the --no-unstable-rust flag to a --unstable-rust flag in src/options.rs
- changing bindgen-flags header in the test headers to remove the --no-unstable-rust flag
- removing --no-unstable-rust flag in ./test/test-one.sh

Fixes #757

r? @fitzgen
2017-06-19 15:45:08 -07:00
Pierre-Antoine Rault
41db162348 switch defaults from generating unstable Rust to generating stable Rust
- changing the Builder::no_unstable_rust method to the Builder::unstable_rust method
- changing the --no-unstable-rust flag to a --unstable-rust flag in src/options.rs
- changing bindgen-flags header in the test headers to remove the --no-unstable-rust flag

Fixes #757
2017-06-19 23:35:07 +02:00