rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

newtype-enum regex nigthmare

Open Dushistov opened this issue 2 years ago • 1 comments

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, FLErrorandC4Foo` are good.

Input C/C++ Header

enum class C4ReplicatorActivity : int { S1, S2, S3 };

enum class FLError { A, B };

enum class C4Foo { C, D };

Dushistov avatar Apr 26 '22 17:04 Dushistov

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).

kulp avatar Jun 02 '22 10:06 kulp

Solved via #2345

pvdrz avatar Nov 14 '22 17:11 pvdrz