[Mesa-dev] [PATCH 25/41] glapi: gl_XML.py: simplify is_attr_true

Dylan Baker baker.dylan.c at gmail.com
Fri Apr 1 00:04:42 UTC 2016


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):
-- 
2.8.0



More information about the mesa-dev mailing list