[Mesa-dev] [PATCH 2/7] genxml: Make classes descendants of object

Jason Ekstrand jason at jlekstrand.net
Tue May 31 21:31:40 UTC 2016


On Tue, May 31, 2016 at 2:30 PM, Dylan Baker <dylan at pnwbakers.com> wrote:

> This is the default in python3, but in python2 you get old style
> classes. No one likes old-style classes.
>
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>  src/intel/genxml/gen_pack_header.py | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/src/intel/genxml/gen_pack_header.py
> b/src/intel/genxml/gen_pack_header.py
> index 2920ec9..ddaa234 100644
> --- a/src/intel/genxml/gen_pack_header.py
> +++ b/src/intel/genxml/gen_pack_header.py
> @@ -168,6 +168,7 @@ __gen_ufixed(float v, uint32_t start, uint32_t end,
> uint32_t fract_bits)
>
>  """
>
> +
>

Lots of extra new lines in this patch


>  def to_alphanum(name):
>      substitutions = {
>          ' ': '',
> @@ -196,6 +197,7 @@ def to_alphanum(name):
>
>      return name
>
> +
>  def safe_name(name):
>      name = to_alphanum(name)
>      if not str.isalpha(name[0]):
> @@ -203,6 +205,7 @@ def safe_name(name):
>
>      return name
>
> +
>  def num_from_str(num_str):
>      if num_str.lower().startswith('0x'):
>          return int(num_str, base=16)
> @@ -210,7 +213,8 @@ def num_from_str(num_str):
>          assert(not num_str.startswith('0') and 'octals numbers not
> allowed')
>          return int(num_str)
>
> -class Field:
> +
> +class Field(object):
>      ufixed_pattern = re.compile("u(\d+)\.(\d+)")
>      sfixed_pattern = re.compile("s(\d+)\.(\d+)")
>
> @@ -279,7 +283,8 @@ class Field:
>          for value in self.values:
>              print("#define %-40s %d" % (prefix + value.name,
> value.value))
>
> -class Group:
> +
> +class Group(object):
>      def __init__(self, parser, parent, start, count, size):
>          self.parser = parser
>          self.parent = parent
> @@ -467,12 +472,14 @@ class Group:
>              print("   dw[%d] = %s;" % (index, v))
>              print("   dw[%d] = %s >> 32;" % (index + 1, v))
>
> -class Value:
> +
> +class Value(object):
>      def __init__(self, attrs):
>          self.name = safe_name(attrs["name"])
>          self.value = int(attrs["value"])
>
> -class Parser:
> +
> +class Parser(object):
>      def __init__(self):
>          self.parser = xml.parsers.expat.ParserCreate()
>          self.parser.StartElementHandler = self.start_element
> @@ -631,6 +638,7 @@ class Parser:
>          self.parser.ParseFile(file)
>          file.close()
>
> +
>  if len(sys.argv) < 2:
>      print("No input xml file specified")
>      sys.exit(1)
> --
> 2.8.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160531/6db1441a/attachment-0001.html>


More information about the mesa-dev mailing list