rust-bindgen
rust-bindgen copied to clipboard
newtype-enum regex nigthmare
I want convert all enums that name matches "C4.*" as newtype-enum
, except enum C4ReplicatorActivity
,
which I want convert as rustified-enum
.
Plus I want convert enum FLError
as newtype-enum
.
I tried several variants (bindgen 0.59.2):
$ bindgen --rustified-enum C4ReplicatorActivity --newtype-enum '(C4(?!ReplicatorActivity)(.+))|(FLError)' /tmp/test2.hpp -- -x c++
C4ReplicatorActivity
ok, FLError
and C4Foo
are not newtype-enum.
$ bindgen --rustified-enum C4ReplicatorActivity --newtype-enum 'FLError' --newtype-enum 'C4.*' /tmp/test2.hpp -- -x c++
C4ReplicatorActivity
not rustfied, FLErrorand
C4Foo` are good.
Input C/C++ Header
enum class C4ReplicatorActivity : int { S1, S2, S3 };
enum class FLError { A, B };
enum class C4Foo { C, D };
Thanks for the report, @Dushistov.
In your first example: if you put an extra set of parentheses around the pattern, resulting in ((C4(?!ReplicatorActivity)(.+))|(FLError))
, does it start working as you expect?
Especially if it does (but even if it does not), this issue might overlap with #1755, and could be fixed by #1756 (although there might be a separate bug in your second example).
Solved via #2345