mirror of
https://gitlab.freedesktop.org/xorg/lib/libxcb-errors.git
synced 2026-01-03 18:40:14 +01:00
extensions.py: pass output by reference
Instead of using a global for it.
This commit is contained in:
parent
0a86215ac8
commit
d63f2942c1
1 changed files with 30 additions and 30 deletions
|
|
@ -81,6 +81,34 @@ def parseFile(filename):
|
|||
assert xproto == None
|
||||
xproto = mod
|
||||
|
||||
def format_strings(name, table, output):
|
||||
if table is None:
|
||||
output.write("\t.num_%s = 0,\n" % name)
|
||||
output.write("\t.strings_%s = NULL,\n" % name)
|
||||
else:
|
||||
if len(table) == 256:
|
||||
# This must be xproto and the value isn't used, so instead use
|
||||
# something that fits into uint8_t.
|
||||
output.write("\t.num_%s = 0,\n" % (name))
|
||||
else:
|
||||
output.write("\t.num_%s = %d,\n" % (name, len(table)))
|
||||
output.write("\t.strings_%s = \"%s\\0\",\n" % (name, "\\0".join(table)))
|
||||
|
||||
def emit_module(module, output):
|
||||
t = ""
|
||||
prefix = "extension_"
|
||||
if module.is_ext:
|
||||
t = "static "
|
||||
else:
|
||||
prefix = ""
|
||||
output.write("%sconst struct static_extension_info_t %s%s_info = { // %s\n" % (t, prefix, module.name, module.xname))
|
||||
format_strings("minor", module.requests_table, output)
|
||||
format_strings("events", module.events_table, output)
|
||||
format_strings("xge_events", module.xge_events_table, output)
|
||||
format_strings("errors", module.errors_table, output)
|
||||
output.write("\t.name = \"%s\",\n" % module.name)
|
||||
output.write("};\n\n")
|
||||
|
||||
# Parse the xml file
|
||||
output_file = sys.argv[1]
|
||||
for input_file in sys.argv[2:]:
|
||||
|
|
@ -94,37 +122,9 @@ output.write("#include \"errors.h\"\n")
|
|||
output.write("#include <string.h>\n")
|
||||
output.write("\n")
|
||||
|
||||
def format_strings(name, table):
|
||||
if table is None:
|
||||
output.write("\t.num_%s = 0,\n" % name)
|
||||
output.write("\t.strings_%s = NULL,\n" % name)
|
||||
else:
|
||||
if len(table) == 256:
|
||||
# This must be xproto and the value isn't used, so instead use
|
||||
# something that fits into uint8_t.
|
||||
output.write("\t.num_%s = 0,\n" % (name))
|
||||
else:
|
||||
output.write("\t.num_%s = %d,\n" % (name, len(table)))
|
||||
output.write("\t.strings_%s = \"%s\\0\",\n" % (name, "\\0".join(table)))
|
||||
|
||||
def emit_module(module):
|
||||
t = ""
|
||||
prefix = "extension_"
|
||||
if module.is_ext:
|
||||
t = "static "
|
||||
else:
|
||||
prefix = ""
|
||||
output.write("%sconst struct static_extension_info_t %s%s_info = { // %s\n" % (t, prefix, module.name, module.xname))
|
||||
format_strings("minor", module.requests_table)
|
||||
format_strings("events", module.events_table)
|
||||
format_strings("xge_events", module.xge_events_table)
|
||||
format_strings("errors", module.errors_table)
|
||||
output.write("\t.name = \"%s\",\n" % module.name)
|
||||
output.write("};\n\n")
|
||||
|
||||
for module in modules:
|
||||
emit_module(module)
|
||||
emit_module(xproto)
|
||||
emit_module(module, output)
|
||||
emit_module(xproto, output)
|
||||
|
||||
output.write("int register_extensions(xcb_errors_context_t *ctx, xcb_connection_t *conn)\n");
|
||||
output.write("{\n");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue