py: Support controls that are ControlTypeNone

Such controls can now be created when a control doesn't have a
reasonable or obvious default value. We support them using Python's
"None" value, rather than generating a runtime error.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Christian Rauch <Rauch.Christian@gmx.de>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
David Plowman 2022-09-30 13:18:12 +01:00 committed by Laurent Pinchart
parent daec83536d
commit c97cf467ea

View file

@ -55,6 +55,7 @@ py::object controlValueToPy(const ControlValue &cv)
return py::cast(v);
}
case ControlTypeNone:
return py::none();
default:
throw std::runtime_error("Unsupported ControlValue type");
}
@ -91,6 +92,7 @@ ControlValue pyToControlValue(const py::object &ob, ControlType type)
case ControlTypeSize:
return ControlValue(ob.cast<Size>());
case ControlTypeNone:
return ControlValue();
default:
throw std::runtime_error("Control type not implemented");
}