diff --git a/tools/spec.py b/tools/spec.py index 18f356f..df3f921 100644 --- a/tools/spec.py +++ b/tools/spec.py @@ -422,17 +422,12 @@ class Command(Type): def is_pointer(self): return '*' in self.param - def __init__(self, node): - assert node.tag == "command" - proto = node.find('proto') - name = proto.find('name').text + def __init__(self, name: str, result: str, params: List[Param], depends: List[str] = None): super().__init__(name) - self.result = proto.find('type').text - self.params = [self.Param(p) for p in node.findall('./param')] - self.depends += [self.result] - for p in self.params: - self.depends += p.depends + self.result = result + self.params = params + self.depends += depends or [] def declare(self): return 'extern "C" %(result)s %(name)s (%(params)s) noexcept;' % { @@ -687,7 +682,16 @@ def parse_commands(reg: Registry, root): reg.types[name] = AliasValue(name, node.attrib['alias']) continue - reg.types[name] = Command(node) + proto = node.find('proto') + name = proto.find('name').text + + result = proto.find('type').text + params = [Command.Param(p) for p in node.findall('./param')] + depends = [result] + for p in params: + depends += p.depends + + reg.types[name] = Command(name, result, params, depends) # -----------------------------------------------------------------------------