On Thu, May 23, 2024 at 2:32 AM Kent Gibson <warthog618@xxxxxxxxx> wrote: > > On Thu, May 23, 2024 at 07:57:12AM +0800, Kent Gibson wrote: > > On Wed, May 22, 2024 at 09:22:50AM -0700, brgl@xxxxxxxx wrote: > > > On Wed, 22 May 2024 02:46:41 +0200, Kent Gibson <warthog618@xxxxxxxxx> said: > > > > While writing a gpiod plugin for gpiozero (Python), I had to map line.Value > > > > to its bool equivalent. Casting seemed the obvious way to go, as it is > > > > essentially a boolean, but that didn't work as I expected - it always > > > > returned True. This is the case for any Python type that does not provide > > > > a suitable conversion operator. > > > > > > > > This series adds support for casting line.Value to bool. > > > > > > > > > > Ha! Interesting. Do you think we may need it anywhere else too? > > > > > > > I guess the same applies to the C++ and Rust bindings - I'll have to > > check. > > > > Or do you mean other fields? There wasn't anything in line.py - all the > other enums are non-binary. And nothing else springs to mind. Yeah, I meant other Python classes. C++ is fine, the cast from enum to int is unambiguous. For Rust I don't know but I'm seeing things like IntMap<Value> in the code, I suppose, enums map fine if nobody complained yet (given rust would most likely not build at all if it didn't handle this case). Bart