[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2f40b41d-600b-435f-804b-216990cf45cd@ryhl.io>
Date: Sun, 5 Nov 2023 12:03:34 +0100
From: Alice Ryhl <alice@...l.io>
To: Gary Guo <gary@...yguo.net>
Cc: Wedson Almeida Filho <walmeida@...rosoft.com>,
Vlastimil Babka <vbabka@...e.cz>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...sung.com>,
Alice Ryhl <aliceryhl@...gle.com>,
Martin Rodriguez Reboredo <yakoyoku@...il.com>,
Vincenzo Palazzo <vincenzopalazzodev@...il.com>
Subject: Re: [PATCH v2] rust: bindings: rename const binding using sed
On 11/4/23 15:56, Gary Guo wrote:
> Current for consts that bindgen don't recognise, we define a helper
> constant with
>
> const <TYPE> BINDINGS_<NAME> = <NAME>;
>
> in `bindings_helper.h` and then we put
>
> pub const <NAME>: <TYPE> = BINDINGS_<NAME>;
>
> in `bindings/lib.rs`. This is fine that we currently only have 3
> constants that are defined this way, but is going to be more annoying
> when more constants are added since every new constant needs to be
> defined in two places.
>
> This patch changes the way we define constant helpers to
>
> const <TYPE> RUST_CONST_HELPER_<NAME> = <NAME>;
>
> and then use `sed` to postprocess Rust code by generated by bindgen to
> remove the distinct prefix, so user of the binding crate can refer to
> the name directly.
>
> Reviewed-by: Benno Lossin <benno.lossin@...ton.me>
> Reviewed-by: Andreas Hindborg <a.hindborg@...sung.com>
> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@...il.com>
> Signed-off-by: Gary Guo <gary@...yguo.net>
Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>
Powered by blists - more mailing lists