Age | Commit message (Collapse) | Author |
|
* Generate extern wrappers for inlined functions
If bindgen finds an inlined function and the
`--generate-extern-functions` options is enabled, then:
- It will generate two new source and header files with external
functions that wrap the inlined functions.
- Rerun `Bindings::generate` using the new header file to include these
wrappers in the generated bindings.
The following additional options were added:
- `--extern-function-suffix=<suffix>`: Adds <suffix> to the name of each
external wrapper function (`__extern` is used by default).
- `--extern-functions-file-name=<name>`: Uses <name> as the file name
for the header and source files (`extern` is used by default).
- `--extern-function-directory=<dir>`: Creates the source and header
files inside <dir> (`/tmp/bindgen` is used by default).
The C code serialization is experimental and only supports a very
limited set of C functions.
Fixes #1090.
---------
Co-authored-by: Amanjeev Sethi <aj@amanjeev.com>
|
|
This PR introduces a new non-exhaustive `struct` called `DeriveInfo` to be used as the sole argument of `ParseCallbacks::add_derives` with the purpose of being able to extend the information passed to this method in a backwards-compatible manner, meaning that adding new fields to `DeriveInfo` won't be a breaking change when releasing a new version.
|
|
remove `clap` dependency :tada:
update the book installation instructions
|
|
[skip ci]
|
|
|
|
|
|
Adding a custom derive like "serde::Deserialize" results in a panic complaining
that it is not a valid Ident. Derive params are not identifiers, so treat it as
a token stream instead.
|
|
|
|
|
|
Custom derives are just as useful on enums as they are on structs; not
supporting this was an oversight.
Adds a test that will fail to compile if the custom derive doesn't work
on enums. This test fails without the codegen fix.
|
|
This test derives PartialEq for the Test struct, and then attempts to
use that by calling assert_ne! on two Test instances. If the derive
callback doesn't work, no PartialEq will be present and the test will
fail to compile.
|
|
|
|
For the commandline arguments I added undocumented aliases to old flags,
to stay backwards compatible.
|
|
Instead of always generating the _bindgen_union_align method (which
shouldn't be needed at all for Rust structs, since the struct layout
tracker already deals with adding repr(align) as necessary) make sure to
visit all fields appropriately to generate the correct alignment.
|
|
|
|
|
|
|
|
|
|
|
|
space.
Fixes #1947.
There are two separate issues here: First, the change in comp.rs ensures
that we don't round up the amount of storage to the alignment of the
bitfield. That generates the "expected" output in #1947
(`__BindgenBitfieldUnit<[u8; 3], u16>`).
But that's still not enough to fix that test-case because
__BindgenBitfieldUnit would be aligned and have padding, and Rust won't
put the extra field in the padding.
In order to ensure the bitfield starts at the right alignment, but that
Rust can put stuff in the extra field, we need to make a breaking change
and split the generated fields in two: One preceding that guarantees
alignment, and the actual storage, bit-aligned.
This keeps the existing behavior while fixing that test-case.
|
|
|
|
|
|
|
|
|
|
|
|
Cleanup a bit the reformatted bits while at it.
|
|
|
|
Alignment arrays are not needed anymore, since we have repr(align).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fixes #1345
|
|
|
|
|
|
callbacks: Introduce MacroParsingBehavior to allow ignoring macros.
This is symmetric, yet less powerful, than enum_variant_behavior.
Fixes #687.
|
|
This is symmetric, yet less powerful, than enum_variant_behavior.
Fixes #687.
|
|
Fixes #1133.
|
|
Fixes #1197.
|
|
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.
|
|
Also:
* disable rustfmt in the integration test, to avoid it causing problems, since
it is not needed.
* note the need to rebuild bindgen when running a single test.
|
|
|
|
Also simplifies the logic that determines which enum variation gets chosen.
|
|
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
|
|
- 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
|
|
|
|
In particular, the "flush the allocation unit" logic is only valid for
ms_structs (that is, MSVC).
It's slightly annoying to have this different behavior, but it'd work just fine
if we'd turn that on for MSVC.
This patch doesn't do that, yet at least, and adds tests for all the weird
bitfield alignments around.
Fixes #726 (and another set of hidden issues by the old code).
|
|
Rather than having a tests that we only run if libclang >= 3.9, this makes the
test suite dynamically detect when we have different expectations for different
libclang versions. It does this by adding `tests/expectations/tests/libclang-$VERSION`
directories, and `testing_only_libclang_$VERSION` features that are consulted
when the usual expectation file does not exist.
Fixes #697
|