Commit e97f7306 authored by Will Thompson's avatar Will Thompson 🐡 Committed by Kalev Lember

gdbus-codegen: make --interface-info-{header,body} not crash

Since 1217b1bc, LICENSE_STR has taken two
parameters, not one. Without this change, running either mode fails
with a traceback like:

    Traceback (most recent call last):
      File "../gdbus-codegen", line 55, in <module>
        sys.exit(codegen_main.codegen_main())
      File ".../codegen_main.py", line 294, in codegen_main
        gen.generate()
      File ".../codegen.py", line 896, in generate
        self.generate_body_preamble()
      File ".../codegen.py", line 682, in generate_body_preamble
        self.outfile.write(LICENSE_STR.format(config.VERSION))
    IndexError: tuple index out of range

8916874e, which introduced these flags,
was actually merged after that commit, but I assume it was written
beforehand.
parent f933e49c
......@@ -619,17 +619,19 @@ class HeaderCodeGenerator:
# ----------------------------------------------------------------------------------------------------
class InterfaceInfoHeaderCodeGenerator:
def __init__(self, ifaces, namespace, header_name, use_pragma, outfile):
def __init__(self, ifaces, namespace, header_name, input_files_basenames, use_pragma, outfile):
self.ifaces = ifaces
self.namespace, self.ns_upper, self.ns_lower = generate_namespace(namespace)
self.header_guard = header_name.upper().replace('.', '_').replace('-', '_').replace('/', '_').replace(':', '_')
self.input_files_basenames = input_files_basenames
self.use_pragma = use_pragma
self.outfile = outfile
# ----------------------------------------------------------------------------------------------------
def generate_header_preamble(self):
self.outfile.write(LICENSE_STR.format(config.VERSION))
basenames = ', '.join(self.input_files_basenames)
self.outfile.write(LICENSE_STR.format(config.VERSION, basenames))
self.outfile.write('\n')
if self.use_pragma:
......@@ -670,16 +672,18 @@ class InterfaceInfoHeaderCodeGenerator:
# ----------------------------------------------------------------------------------------------------
class InterfaceInfoBodyCodeGenerator:
def __init__(self, ifaces, namespace, header_name, outfile):
def __init__(self, ifaces, namespace, header_name, input_files_basenames, outfile):
self.ifaces = ifaces
self.namespace, self.ns_upper, self.ns_lower = generate_namespace(namespace)
self.header_name = header_name
self.input_files_basenames = input_files_basenames
self.outfile = outfile
# ----------------------------------------------------------------------------------------------------
def generate_body_preamble(self):
self.outfile.write(LICENSE_STR.format(config.VERSION))
basenames = ', '.join(self.input_files_basenames)
self.outfile.write(LICENSE_STR.format(config.VERSION, basenames))
self.outfile.write('\n')
self.outfile.write('#ifdef HAVE_CONFIG_H\n'
'# include "config.h"\n'
......
......@@ -281,6 +281,7 @@ def codegen_main():
gen = codegen.InterfaceInfoHeaderCodeGenerator(all_ifaces,
args.c_namespace,
header_name,
input_files_basenames,
args.pragma_once,
outfile)
gen.generate()
......@@ -290,6 +291,7 @@ def codegen_main():
gen = codegen.InterfaceInfoBodyCodeGenerator(all_ifaces,
args.c_namespace,
header_name,
input_files_basenames,
outfile)
gen.generate()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment