Commit Graph

2994 Commits

Author SHA1 Message Date
simlay
f39c4a95cb An initial implementation of objective-c generics for #1259 (#1702) 2020-01-05 14:04:15 +01:00
John Brandt
899f5992c7 Update latest stable rust to 1.40 and give non_exhaustive feature 2019-12-20 03:09:26 +01:00
Kornel
d4e4a996e8
Remove deprecated Error::description 2019-12-16 12:00:33 +01:00
Conor McAvity
5d38f2aca6 Remove size_t to usize conversion rule 2019-12-13 23:03:15 +01:00
Emilio Cobos Álvarez
b3c3980d23
codegen: Minor cleanup after #1691. 2019-12-11 03:14:19 +01:00
Emilio Cobos Álvarez
560354e4f1
tests: Minor rustc warning fixes. 2019-12-11 03:13:46 +01:00
Jasper-Bekkers
09f6c1d921 Add support for wasm_import_module 2019-12-11 01:48:01 +01:00
Jake Merdich
7d61f36a5b Fix warning on rustdoc
Rustdoc was treating doc comments containing `#[non_exhaustive]`
as links and warning, so mark that as code to avoid the warning.
2019-11-28 16:25:26 +01:00
Luca Barbato
880de82108 Move warnings check on the CI
Always building with `deny(warnings)` leads to messups such as
https://docs.rs/crate/bindgen/0.52.0/builds/199624
2019-11-25 17:35:45 +01:00
Emilio Cobos Álvarez
b44be6e3db
v0.52.0 2019-11-19 16:59:38 +01:00
David Vo
5f4dc4f458 Make rustfmt happy 2019-11-14 17:35:38 +01:00
David Vo
ac498475e0 Add newtype enum style
This adds an enum style similar to the existing bitfield style, without
the bitwise operator impls.

Closes: #1669
2019-11-14 17:35:38 +01:00
Jon Gjengset
f27fe97089 Warn rather than panic on unknown namespace prefix
When a #defined token was used before a namespace, like so (#1676):

    #define nssv_inline_ns inline
    nssv_inline_ns namespace literals {}

bindgen would crash when encountering the unknown token preceding the
namespace token. This is because we don't get to see "past" the ifdef to
the underlying token. The true fix to this is to find a way to extract
ifdef info through clang, but for the time being we simply change the
panic into a warning when such a token is encountered, and then proceed
as if it were empty.

Fixes #1676.
2019-11-14 15:10:05 +01:00
Elichai Turkel
8d85c3b2cf Update tests from transmute to 'as' casting 2019-11-09 18:42:10 +01:00
Elichai Turkel
0ca63228e1 Replace unsafe ref->ptr transmute with 'as' casting 2019-11-09 18:42:10 +01:00
Joseph Rafael Ferrer
1c31f29e4e Option to use #[repr(transparent)] structs instead of type aliasing. 2019-11-08 14:08:09 +01:00
Elichai Turkel
3609bd6ecb Update and add tests for MaybeUninit 2019-11-08 13:46:40 +01:00
Elichai Turkel
99aff6e254 Add support for MaybeUninit 2019-11-08 13:46:40 +01:00
Ilia Kravets
ec35b7ab7e Update cexpr dependency 2019-11-08 13:45:45 +01:00
David Frey
ec85170cb1 Do not generate implementation for clone for FAM
Flexible array members are represented in the generated binding by a
struct __IncompleteArrayField<T>. Since such members do not contain any
information about how big they are, it is impossible to automatically
clone or copy them, either in C or rust.

Fixes #1431.
2019-11-03 23:35:24 +01:00
Emilio Cobos Álvarez
79b2b10420
Move rust feature docs into a more useful place. 2019-10-28 20:08:03 +01:00
Danny Bautista
18a64e60b3 Turn off regex default features. 2019-10-27 00:07:58 +02:00
Robbie Harwood
0ecf7c92f5 [book] Update most recent version of bindgen
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2019-10-26 14:10:29 +02:00
oblique
cb82666205
Add disable_nested_struct_naming option (#1610)
The following structs have different names for C and C++. In case of C
they are visible as `foo` and `bar`. In case of C++ they are visible as
`foo` and `foo::bar`. By default bindgen follows C++ naming to avoid
generating duplicate names.

With this option the following structs will be named as `foo`
and `bar` instead of `foo` and `foo_bar`.

```
struct foo {
    struct bar {
    } b;
};
```

In case of an unnamed definition we build the canonical name from
the inner most named definition. For example the following will
generate `baz__bindgen_ty_1`:

```
struct foo {
    struct bar {
        struct baz {
            struct {
            } u;
        } z;
    } b;
};
```

This option should be used only for C headers. It is needed in some
rare situations where user used another code generator that already
mangled nested definitions.

A real life example is [asn1c] with `-fcompound-names` option.

[asn1c]: https://github.com/vlm/asn1c
2019-10-22 22:21:21 +02:00
Emilio Cobos Álvarez
fa6a68d7c7 codegen: Handle opaque aliases to enums correctly.
Opaque types don't use the path to their aliased type but an opaque type like an
array or primitive with the right alignment.

Fixes #1599.
2019-10-22 17:48:52 +02:00
Emilio Cobos Álvarez
c462b63ec4 Test the runtime feature and the non-static linking.
We can't test the "static" code-path, since there are no prebuilt binaries in
releases.llvm.org.
2019-10-21 23:06:10 +02:00
Emilio Cobos Álvarez
fac5cbb519 Cargo fmt. 2019-10-21 23:06:10 +02:00
Jeremy Fitzhardinge
5915768cb0 Allow static and dynamic linking
Currently bindgen always uses clang-sys with the "runtime" feature -
that is, load libclang at runtime with dlopen (or similar)
at runtime.  This PR keeps this default, but also
- adds "static" to statically link libclang
- without either "runtime" or "static", link with the shared library

Many distributions don't ship with a static libclang, but linking with the dynamic
library will use normal ld.so mechanisms to define where the .so file should be found.
(Ditto for the Mac and Windows equivalents.)
2019-10-21 23:06:10 +02:00
Emilio Cobos Álvarez
3e1b714498
Rustfmt to account for rebase. 2019-10-14 15:14:19 +02:00
Emilio Cobos Álvarez
f686751099 Fix bitfield-linux-32.hpp to not hit #1538.
The test was failing.
2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
d52622e018 bindgen-integration: Reformat crate too.
Cleanup a bit the reformatted bits while at it.
2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
a38c046a06 tests: Remove support for test directive that is no longer used.
ae0fdf7a55 changed the setup for the only test
that actually used this.
2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
5324c3e4aa Enforce rustfmt on automation. 2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
d6a419796d Run cargo fmt on the main crate. 2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
94b0af83e6 tests: Reformat test crate.
Now that the rustfmt configuration is different we need to do this to not
generate unexpected failures.
2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
4f3452f6f6 tests: Use the same rustfmt configuration as the parent directory.
This allows us to workaround/fix
https://github.com/rust-lang/rustfmt/issues/3799
2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
d3727cd36e tests: Fix some warning in the test crate. 2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
cd4f0043fb Add llvm 9.0 to CI. 2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
5591a10355 Update test expectations for libclang 9.0. 2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
601baa2f6b Create clang-9-specific test directory, as a copy of clang-5. 2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
acc7664428 tests: Look at expectations/tests/libclang-9 expectations. 2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
1216622a40 tests: Look at the more specific tests first, but don't require specific expectations for all llvm versions. 2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
71e0d9d5a7 function: Fix #[must_use] support in libclang 9+. 2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez
5d1c517d13 features: core::ffi::c_void isn't really available before 1.30. 2019-10-14 14:15:46 +02:00
Cameron McCormack
22b1094189 Fix BitfieldUnit constructor to handle 64 bit wide bitfields on 32 bit.
Fixes #1639.
2019-10-08 14:38:35 +02:00
Cameron McCormack
807fa1e959 Rename Item::canonical_name_cache for consistency. 2019-10-08 01:40:07 +02:00
Cameron McCormack
a7fb8bff61 Use a LazyCell for Item::canonical_name_cache and Item::local_id.
It's slightly neater.
2019-10-08 01:40:07 +02:00
Cameron McCormack
fa3f7896da Cache the result of Item::path_for_whitelisting. 2019-10-08 01:40:07 +02:00
chrysn
49af9b76b8
Add ParseCallbacks handler for included files
As the clang_File_tryGetRealPathName function is only exposed by
clang_sys for clang >= 7.0, this raises the clang dependency.

Closes: https://github.com/rust-lang/rust-bindgen/issues/1635

The book example code for creating a builder to run inside Cargo is
extended by using the rereun-if-changed headers.
2019-10-08 01:31:49 +02:00
Cameron McCormack
b84fb5b15e Don't always output translation_unit timer. 2019-10-08 01:30:40 +02:00