Commit e288d9fb authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

Make gen_xproto.py work with Python 3.

- Tuple parameter unpacking was removed in Python 3, so adjust
  type_order_priority() accordingly.
- |cmp| as a parameter for list.sort() was removed in Python 3, use
  functools.cmp_to_key().

Bug: 941669
Change-Id: Icafb2024c77a335e5dd043be066f414a38f14b63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2236404
Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776606}
parent febdf3b6
......@@ -168,6 +168,7 @@ from __future__ import print_function
import argparse
import collections
import functools
import os
import re
import sys
......@@ -1060,7 +1061,8 @@ class GenXproto(FileWriter):
# The order of types in xcbproto's xml files are inconsistent, so sort
# them in the order {type aliases, enums, xidunions, structs,
# requests/replies}.
def type_order_priority((name, item)):
def type_order_priority(module_type):
name, item = module_type
if item.is_simple:
return 2 if self.get_xidunion_element(name) else 0
if isinstance(item, self.xcbgen.xtypes.Enum):
......@@ -1073,7 +1075,7 @@ class GenXproto(FileWriter):
return type_order_priority(type1) - type_order_priority(type2)
# sort() is guaranteed to be stable.
self.module.all.sort(cmp=cmp)
self.module.all.sort(key=functools.cmp_to_key(cmp))
def gen_header(self):
self.file = self.header_file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment