tools/spec: make main an actual function
This reduces variable shadowing across the rest of the file
This commit is contained in:
parent
09c9ff741a
commit
06e29cb474
@ -45,7 +45,7 @@ class Registry:
|
||||
required = []
|
||||
|
||||
for (_, f) in self.features.items():
|
||||
required += f.apply(reg)
|
||||
required += f.apply(self)
|
||||
required.append(f.name)
|
||||
|
||||
for e in self.extensions:
|
||||
@ -84,7 +84,7 @@ class Type(object):
|
||||
def declare(self):
|
||||
return ""
|
||||
|
||||
def define(self,reg):
|
||||
def define(self, reg: Registry):
|
||||
return ""
|
||||
|
||||
|
||||
@ -695,7 +695,7 @@ def parse_commands(reg: Registry, root):
|
||||
def parse_feature(reg: Registry, root):
|
||||
assert root.tag == 'feature'
|
||||
|
||||
name = node.attrib['name']
|
||||
name = root.attrib['name']
|
||||
assert name not in reg.features
|
||||
|
||||
reg.features[name] = Feature(root)
|
||||
@ -714,7 +714,7 @@ def parse_extensions(reg: Registry, root):
|
||||
|
||||
|
||||
###############################################################################
|
||||
def write_header(path: str, q: List[Type]):
|
||||
def write_header(path: str, q: List[Type], reg: Registry):
|
||||
with open(path, 'w') as dst:
|
||||
dst.write("#pragma once\n")
|
||||
|
||||
@ -766,7 +766,7 @@ def write_header(path: str, q: List[Type]):
|
||||
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
def write_icd(path: str, q: List[Type]):
|
||||
def write_icd(path: str, q: List[Type], reg: Registry):
|
||||
with open(path, 'w') as icd:
|
||||
commands = [i for i in q if isinstance(i, Command)]
|
||||
instance_commands = [i for i in commands if i.is_instance(reg)]
|
||||
@ -813,7 +813,7 @@ def write_icd(path: str, q: List[Type]):
|
||||
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
def write_dispatch(path: str, q: List[Type]):
|
||||
def write_dispatch(path: str, q: List[Type], reg: Registry):
|
||||
with open(path, 'w') as dispatch:
|
||||
dispatch.write("""
|
||||
#include "../vk.hpp"
|
||||
@ -884,7 +884,7 @@ import argparse
|
||||
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
logging.getLogger().setLevel(logging.WARNING)
|
||||
|
||||
parser = argparse.ArgumentParser(description='Transform XML API specification into C++ headers')
|
||||
@ -935,6 +935,10 @@ if __name__ == '__main__':
|
||||
q = reg.serialise(args.platform)
|
||||
|
||||
# Finally write out the header, icd, and dispatch code.
|
||||
write_header(args.dst, q)
|
||||
write_icd(args.icd, q)
|
||||
write_dispatch(args.dispatch, q)
|
||||
write_header(args.dst, q, reg)
|
||||
write_icd(args.icd, q, reg)
|
||||
write_dispatch(args.dispatch, q, reg)
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user