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:
parent
daec83536d
commit
c97cf467ea
1 changed files with 2 additions and 0 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue