[Mesa-dev] [PATCH 25/41] glapi: gl_XML.py: simplify is_attr_true
Ian Romanick
idr at freedesktop.org
Tue Apr 19 23:25:51 UTC 2016
This patch is
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
On 03/31/2016 05:04 PM, Dylan Baker wrote:
> Use a boolean instead of 0 or 1, and use an assert rather than a runtime
> error.
>
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
> src/mapi/glapi/gen/gl_XML.py | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
> index 334fd6e..34f987e 100644
> --- a/src/mapi/glapi/gen/gl_XML.py
> +++ b/src/mapi/glapi/gen/gl_XML.py
> @@ -66,15 +66,13 @@ def is_attr_true(element, name, default="false"):
> The value read from the attribute list must be either 'true' or
> 'false'. If the value is 'false', zero will be returned. If the
> value is 'true', non-zero will be returned. An exception will be
> - raised for any other value."""
> + raised for any other value.
>
> + """
> value = element.get(name, default)
> - if value == "true":
> - return 1
> - elif value == "false":
> - return 0
> - else:
> - raise RuntimeError('Invalid value "%s" for boolean "%s".' % (value, name))
> + assert value in ('true', 'false'), 'value {} was not a bool'.format(value)
> +
> + return value == 'true'
>
>
> class gl_print_base(object):
>
More information about the mesa-dev
mailing list