tools/spec: don't use xml nodes in the Command constructor
This commit is contained in:
parent
cfdb2f2bdd
commit
c3d51883cb
@ -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)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user