Commit Graph

1137 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez 3e7db6dc20 rename: Add a test for rename-all=prefix: 2024-10-27 22:21:34 +00:00
Emilio Cobos Álvarez b2e04b612c Less clone for rename-all. 2024-10-27 22:21:34 +00:00
Jeremy Fitzhardinge 03c33969f4 Add rename-all=prefix:
This adds a new rename-all annotation which allows setting a specific
prefix to all fields. For example:

```rust
/// cbindgen:rename-all=prefix:ERR_
enum Error {
   Bad = 0,
   VeryBad = 1
}
```

While in principle this can be added to the config file, it's primarily
useful for overrides on a case-by-case basis.
2024-10-27 22:21:34 +00:00
Jeremy Fitzhardinge 6584efa305 Fix local override of enum prefix-with-name
Fixes #808
2024-10-27 22:07:34 +00:00
Emilio Cobos Álvarez 33a45da7c5 Also update syn in the Cargo.toml. 2024-10-27 22:05:01 +00:00
Emilio Cobos Álvarez 0520480e4f utilities: Minor clean-up. 2024-10-27 22:05:01 +00:00
coekjan 0ac02118b1 Parse unsafe attributes 2024-10-27 22:05:01 +00:00
Ryan Johnson 3ed9434f09 Deduplicate the code that turns transparent structs into typedefs
All zero-sized structs now trigger a warning about undefined behavior,
and an empty struct definition is emitted regardless of whether the user
asked for repr(C) or repr(transparent).
2024-08-14 08:53:26 +01:00
Emilio Cobos Álvarez 58c6156b0d Bump MSRV again for clap. 2024-08-10 10:51:20 +00:00
Emilio Cobos Álvarez 103a8de0ac Cargo update and version bump. 2024-08-10 10:35:30 +00:00
Js2xxx 67cb560430 Update CHANGES since v0.26.0 2024-08-10 10:27:57 +00:00
Flávio J. Saraiva 316298182e Output condition for globals. 2024-06-04 00:57:07 +00:00
Alex Konradi e469e44c00 Add missing parens to log message 2024-06-03 17:52:45 +00:00
Emilio Cobos Álvarez 3cbb637bbf Update cython expectations from the previous patch. 2024-05-29 11:08:50 +02:00
Kan-Ru Chen 785e066e03 Fix variadic arguments when used in function pointer 2024-05-29 08:15:14 +00:00
GrayJack aa8ea654e1 deps: Update syn to 2.0
The variadic function information now is found on its own field, outside
of `Signature.inputs`

Closes #961
2024-05-28 11:26:43 +02:00
Ryan Johnson 9f632843b8 Generalize Item to expose documentation and generic params
Closes #963
2024-05-28 11:16:33 +02:00
Gerard Ryan 1dda6162e5 Used documented method of specifying variadic arguments
`va_list` -> `...`
* https://en.cppreference.com/w/c/language/variadic
* https://en.cppreference.com/w/cpp/language/variadic_arguments
2024-05-28 09:09:18 +00:00
Gerard Ryan 6f13a5d157 Parse function argument type first so it can be used to determine name 2024-05-28 09:09:18 +00:00
Gerard Ryan 62b06e368b Improved test coverage of va_list 2024-05-28 09:09:18 +00:00
Christian Meusel 822bde072b Point out issue with failing builds due to syntax errors
This is a trap "for young players" and loosing feedback from rustc or
your favorite code analysis tools won't make things better. Let's point
out the issue and the solution given in issue #472 upfront.
2024-05-26 16:25:29 +00:00
Ryan Johnson ad8454128f Add support for NonZero<T> and simplify handling of int primitives
Closes #964.
2024-05-26 18:24:28 +02:00
Ryan Johnson c6012a0b30 support generics with defaulted args 2024-05-26 15:58:09 +00:00
Ryan Johnson 9c10488359 handle constants of nested transparent types 2024-05-26 15:55:22 +00:00
Ryan Johnson 751186dd3d make it a dev dependency only 2024-05-26 15:54:41 +00:00
Ryan Johnson 470d8e401a tests use pretty_assertions for readable diffs 2024-05-26 15:54:41 +00:00
Emilio Cobos Álvarez 85de5341c1 chore: Update dependencies.
Updates syn to not crash with c string literals and so on, and other
crates while at it.
2024-05-14 11:17:50 +00:00
Ryan Johnson 6f7cb4326b revert accidentally committed debug code 2024-05-14 11:02:29 +00:00
Gabriel Féron 27fa895c03 Exclude all test crates 2024-05-14 13:01:21 +02:00
Gabriel Féron a5f865da29 Exclude test depfile crates 2024-05-07 15:14:18 +00:00
Gabriel Féron 96297e6c8f Rename duplicate crates in workspace 2024-05-07 15:14:18 +00:00
Ryan Johnson 10f32b0fda bug fixed, update test and expectations 2024-05-07 08:23:38 +00:00
Ryan Johnson 0c82a32443 add panic to check whether parser even sees it 2024-05-07 08:23:38 +00:00
Ryan Johnson 98eefa7497 Expand ignored.rs test to cover associated items 2024-05-07 08:23:38 +00:00
Emilio Cobos Álvarez cdf7d2f15e chore: Fix clippy lints. 2024-05-07 10:20:52 +02:00
Jonathan ca78140c01 Fix cpplint warnings
Closes #865
2024-04-15 08:58:55 -04:00
Jonathan b0ad90a205 Add cpp_compat to template.toml
This adds a mention of `cpp_compat` option to the template file.

#811
2024-04-15 11:35:52 +00:00
Emilio Cobos Álvarez e2114642ae parser: Treat omitted ABI in extern block as "C".
As per https://doc.rust-lang.org/reference/items/external-blocks.html#abi

Closes #709
2024-04-15 01:42:47 +00:00
Emilio Cobos Álvarez 92f9d3b073 Account for cfg items in foreign mods.
Fixes #807
2024-04-15 01:21:33 +00:00
Emilio Cobos Álvarez 49a387e42d bindgen: More language-backend clean-up. 2024-04-14 17:10:45 +00:00
Emilio Cobos Álvarez 9fff78c82e Remove code duplication for function writing, and other minor clean-ups. 2024-04-14 17:10:45 +00:00
Thibaut Lorrain 33546067e7 introduce the concept of language backend 2024-04-14 17:10:45 +00:00
Emilio Cobos Álvarez 8ea849e6d1 ir: Write documentation on static items. 2024-04-14 15:45:26 +00:00
Emilio Cobos Álvarez e0aeb8f7c8 Run CI jobs on the merge queue. 2024-04-14 15:39:48 +00:00
Hitbear af469996e0 Added support for integrating the package_version information in a comment of the header file.
The new command line argument for this is --package-version.

The TOML config file flag is package_version=true||false.

Closes #926
Co-Authored-By: Emilio Cobos Álvarez <emilio@crisal.io>
2024-04-14 15:34:10 +00:00
Benjamin Kästner 400f437643 feat: support #[deprecated] on enum variants
While the #[deprecated] attribute was already used on structs, fns and
enums, it was not implemented for enum variants. The information about
enum variants is already available via `variant.body.annotations`, so
the support for the #[deprecated] attribute on enum-variant level is
more or less only another pair of entries within the `EnumConfig`.

This commit adds two new options within the `[enum]` settings:

- deprecated_variant, and
- deprecated_variant_with_notes

Both get active only on #[deprecated] variants, e.g.,

     #[repr(u8)]
     enum ApiLevel {
         #[deprecated(note = "Legacy Support until 2025")]
         L1 = 1,
         #[deprecated]
         L2 = 2,
         L3 = 3,
         L4 = 4,
    }

For enums with struct variants, the current struct deprecation methods
are already working good enough (see tests/expecations/deprecated*).
2024-04-14 17:19:58 +02:00
Josh Stone bde8ab4852 Use retain in ItemMap::filter 2024-04-14 17:14:28 +02:00
Arthur Meyre f1d5801d3b fix: select package for bindgen based on name and manifest path
- the old code was selecting the first package that was found which meant
that dependencies with the same name could be used for bindgen instead of
the intended package
- a fallback to the old behavior is kept for now in case manifest paths are
not matching because of relative paths for example
- this should be backwards compatible with all cbindgen usage, the
selection bug may still trigger in case the manifest path does not match
2024-02-26 17:59:37 +01:00
Sijie Yang 95047dbf23 Update README.md 2024-02-26 17:58:10 +01:00
Alex Touchet 1f67bea7d8 Update doc link in Readme so it works from docs.rs 2024-02-26 17:57:50 +01:00