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

Since 1217b1bc4f, 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

8916874ee6, which introduced these flags,
was actually merged after that commit, but I assume it was written
beforehand.
This commit is contained in:
Will Thompson 2018-12-05 21:32:05 +00:00
parent 6528887534
commit faa3c319ba
No known key found for this signature in database
GPG Key ID: 3422DC0D7AD482A7
2 changed files with 10 additions and 4 deletions

View File

@ -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'

View File

@ -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()