diff --git a/tools/spec.py b/tools/spec.py index f4969f5..fa3bb85 100644 --- a/tools/spec.py +++ b/tools/spec.py @@ -96,7 +96,7 @@ class AliasType(Type): May be serialised using an appropriate host language facility (eg, a typedef) """ - def __init__(self, name: str, target: str, depends: List[str]=None): + def __init__(self, name: str, target: str, depends: List[str] = None): depends = depends or [] super().__init__(name, depends=depends+[target]) self.target = target @@ -139,7 +139,7 @@ class Unscoped(Type): def declare(self): return "\n".join(t.declare() for t in self.values) - def define(self,reg): + def define(self, reg): return "\n".join(t.define(reg.types) for t in self.values) @@ -286,7 +286,7 @@ class Enum(Type): } def define(self, reg: Registry): - values = ("%(name)s = %(value)s" % { "name": k, "value": v.value } for (k,v) in self.values.items()) + values = ("%(name)s = %(value)s" % {"name": k, "value": v.value} for (k, v) in self.values.items()) return "enum %(name)s : int32_t { %(values)s };" % { "name": self.name, @@ -407,7 +407,7 @@ class Constant(Type): elif 'value' in node.attrib: self.value = node.attrib['value'] elif 'bitpos' in node.attrib: - self.value = "1 << %s" % node.attrib['bitpos'] + self.value = "1 << %s" % node.attrib['bitpos'] else: raise RuntimeError("Unknown constant value type") @@ -425,7 +425,7 @@ class Command(Type): assert node.tag == 'param' super().__init__( - name = node.find('name').text, + name=node.find('name').text, depends=[node.find('type').text], **kwargs ) @@ -489,7 +489,7 @@ class Command(Type): return False return True - def is_device(self, reg:Registry): + def is_device(self, reg: Registry): return not self.is_instance(reg) @@ -608,12 +608,13 @@ class Extension(Type): logging.info("Applying extension:", self.name, file=sys.stderr) for node in self.requires: - required += node.apply(reg,extnumber=self.number) + required += node.apply(reg, extnumber=self.number) return required ############################################################################### -def ignore_node(types:Dict[str, Type], root): +def ignore_node(types: Dict[str, Type], root): + types, root pass parse_comment = ignore_node @@ -643,7 +644,7 @@ def parse_types(reg: Registry, root): # # eg, 'Display' depends on 'X11/Xlib.h' if not category: - reg.types[name] = Placeholder (name) + reg.types[name] = Placeholder(name) else: # Whitelist the known types so we don't accidentally instantiate # something whacky @@ -736,7 +737,6 @@ def write_header(path: str, q: List[Type], reg: Registry): dst.write(obj.define(reg)) dst.write('\n') - # Define the default case for device and instance type traits. dst.write(""" #include @@ -868,7 +868,6 @@ def write_dispatch(path: str, q: List[Type], reg: Registry): else: raise Exception("Unknown param type") - dispatch.write(f""" extern "C" {obj.result} {rename(obj.name)} ({", ".join(p.param for p in obj.params)}) noexcept {{ using first_arg_t = std::decay_t;