intel/genxml: recognize 0x, 0o and 0b when setting default value
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 2 May 2018 21:48:57 +0000 (14:48 -0700)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 4 May 2018 22:58:10 +0000 (23:58 +0100)
Remove the need of converting values that are documented in
hexadecimal. This patch would allow writing

    <field name="3D Command Sub Opcode" ... default="0x1B"/>

instead of

    <field name="3D Command Sub Opcode" ... default="27"/>

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/genxml/gen_pack_header.py

index 8989f625d3120eab2c3ed2f9b8bc6d6ed9d63d43..6a4c8033a70cb8a1965bc1c2653c93ef36139a78 100644 (file)
@@ -241,7 +241,8 @@ class Field(object):
             self.prefix = None
 
         if "default" in attrs:
-            self.default = int(attrs["default"])
+            # Base 0 recognizes 0x, 0o, 0b prefixes in addition to decimal ints.
+            self.default = int(attrs["default"], base=0)
         else:
             self.default = None