Commit Graph

24 Commits

Author SHA1 Message Date
ljy9810 47578c3c78 bitflags升级,配套修改
Signed-off-by: ljy9810 <longjianyin@h-partners.com>
2025-11-13 15:28:56 +08:00
a30054014 b54cf916fe rust-bindgen相关依赖兼容性适配
Signed-off-by: a30054014 <aipeng3@huawei.com>
2025-04-19 16:17:39 +08:00
a30054014 c1e7498e84 rust-bindgen相关依赖兼容性适配
Signed-off-by: a30054014 <aipeng3@huawei.com>
2025-04-19 16:11:11 +08:00
oh_ci 39e4f73eb8 回退 'Pull Request !9 : bindgen升级0.70.1版本' 2025-04-19 06:22:12 +00:00
月出皎兮 83fcd6d5e2 bindgen升级0.70.1版本
Signed-off-by: 月出皎兮 <xietingwei@h-partners.com>
2025-04-15 20:47:01 +08:00
徐未来 f9afaba08a 适配syn升级至2.0
Signed-off-by: 徐未来 <xuweilai2@huawei.com>
2024-04-02 15:05:30 +08:00
Christian Poveda Ruiz bd14f85019 Generate extern wrappers for inlined functions (#2335)
* 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>
2023-02-07 10:13:48 -05:00
Dan Dumont e8f278ed11 Implement cli option for custom derive (#2328)
* custom derives after DeriveInfo

* Introduce `TypeKind` instead of `CompKind`

* Add tests

* Emit CLI flags for callbacks

* update changelog

* run rustfmt

* fix tests

* fix features

Co-authored-by: Christian Poveda <christian.poveda@ferrous-systems.com>
2023-01-20 15:12:42 -05:00
Emilio Cobos Álvarez efc8293c07 codegen: Look through typedefs to detect void return type. (#2379)
* codegen: Look through typedefs to detect void return type.

And reuse a bit more code.

Should fix #2377, but needs a test (can't run tests atm).

* Add tests

* Run rustfmt

* Update changelog

Co-authored-by: Christian Poveda <christian.poveda@ferrous-systems.com>
2023-01-06 13:07:28 -05:00
Emilio Cobos Álvarez a0af678a04 codegen: Do generate field offset checks for classes with multiple bases.
The bug only affects virtual inheritance, so instead disable layout
tests in the test that we know is broken. Not generating layout tests is
wrong anyways, because the offset would be wrong.
2022-12-07 12:18:35 +01:00
David Tolnay 14df65cb32 Fix name collision between C enum and typedef (#2326)
Fixes #2008.

Example:

```c
enum Enum { Variant };
typedef int16_t Enum;
```

This is valid and idiomatic C (though not valid C++). `cbindgen` uses this idiom as the default C translation of Rust enums, the equivalent of what would be `enum Enum : int16_t { Variant };` in C++.

`bindgen header.h` before:

```rust
pub const Enum_Variant: Enum = 0;
pub type Enum = ::std::os::raw::c_uint;
pub type Enum = i16;
```

```console
error[E0428]: the name `Enum` is defined multiple times
 --> generated.rs:3:1
  |
2 | pub type Enum = ::std::os::raw::c_uint;
  | --------------------------------------- previous definition of the type `Enum` here
3 | pub type Enum = i16;
  | ^^^^^^^^^^^^^^^^^^^^ `Enum` redefined here
  |
  = note: `Enum` must be defined only once in the type namespace of this module
```

After:

```rust

pub const Enum_Variant: Enum = 0;
pub type Enum = i16;
```
2022-11-28 09:40:20 -05:00
Christian Poveda Ruiz b898d1c84f Remove traits that have a single implementation (#2363) 2022-11-24 11:17:08 -05:00
Christian Poveda Ruiz 4b3940e6c8 Fix clippy warnings (#2362) 2022-11-24 10:50:15 -05:00
Christian Poveda Ruiz 3b303cc072 Add --wrap-unsafe-ops option (#2354)
This reverts commit fc6c702695 and adds a new `--wrap-unsafe-ops` option as a workaround.
2022-11-22 11:41:32 -05:00
Christian Poveda Ruiz ba546f41c4 Add ParseCallbacks::process_comment (#2347)
This method can be used to process comments and replace them with whatever the user wants.
2022-11-22 11:25:13 -05:00
Christian Poveda Ruiz 0cbd492cc5 Introduce DeriveInfo (#2355)
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.
2022-11-21 10:38:42 -05:00
Christian Poveda Ruiz ab2d1c2e8b Fix duplicated function names (#2341)
Even though this change does name deduplication in a slower way, it
avoids name collisions without any breaking changes in the test suite.

Fixes #2202
2022-11-11 11:48:39 -05:00
Christian Poveda Ruiz fc6c702695 Wrap unsafe function's bodies in unsafe blocks (#2266)
This guarantees that bindings generated by `bindgen` compile even if the `unsafe_op_in_unsafe_fn` lint is denied.
2022-11-04 15:22:49 -05:00
Christian Poveda Ruiz 334f644b1d Add support for the "C-unwind" ABI (#2334)
* Add support for the `"C-unwind"` ABI

This allows using `"C-unwind"` as an ABI override if the rust target is
nightly.
2022-11-04 10:19:28 -05:00
Christian Poveda Ruiz 18ccd45509 Add the --override-abi option (#2329)
* Add the `--override-abi` option.

This option can be used from the CLI with the <abi>:<regex> syntax and
it overrides the ABI of a function if it matches <regex>.

Fixes #2257
2022-11-02 15:30:34 -05:00
Christian Poveda Ruiz 8136142661 Allow callback composition (#2330)
* Allow callback composition

Store all the callbacks added to the builder in a `Vec` so bindgen
invokes each one of them in a last-to-first manner.
2022-11-02 13:46:22 -05:00
Christian Poveda Ruiz 36eb92ba85 Fix clippy warnings (#2331) 2022-11-02 13:32:32 -05:00
Christian Poveda 12c8268404 Make postprocessing more robust
This is done by merging extern blocks and sorting items in every module
instead of just in the root module.

The tests were changed to use `cxx` namespaces so they effectively check
that items are manipulated correctly in every single module.
2022-10-06 14:52:29 -05:00
Christian Poveda 1213b3dfb1 split the repo into a workspace
remove `clap` dependency 🎉

update the book installation instructions
2022-10-04 20:47:17 -05:00