PyFLP
PyFLP copied to clipboard
✨ Comprehensive bounds checking for event values
Problem
Till 2.2.0, non-DATA
events had a value setter. In 2.2.0, I removed event value lazy evaluation entirely.
Now value
is an attribute of EventBase
. Structs as part of list events or child level structs didn't invoke any setters, as they were just dictionaries.
The earlier property setter failed with a ConstructError
or struct.Error
which was non descriptive of what really caused it.
Ideas
Make EventBase.value
a descriptor again. Instead of doing everything in EventBase
ctor, shift the parsing logic to subclasses.
Make this descriptor take in a validator class. For struct-based events, wrap the parsed Container into a special dictionary descriptor which validates every __setitem__ with the correct construct.
List event values could have their own list descriptor wrapper over the struct dictionary descriptors.