[glib/glib-2-58: 1/5] gdbus-codegen: make --interface-info-{header, body} not crash



commit 06e1d72f54e8540236a93c1cc611975c0067ff9f
Author: Will Thompson <will willthompson co uk>
Date:   Wed Dec 5 21:32:05 2018 +0000

    gdbus-codegen: make --interface-info-{header,body} not crash
    
    Since 1217b1bc4f242c14d6eabbee0c688c320eab2e4d, 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
    
    8916874ee6f3ff0f887dbe1eda55c23c2c0097ee, which introduced these flags,
    was actually merged after that commit, but I assume it was written
    beforehand.

 gio/gdbus-2.0/codegen/codegen.py      | 12 ++++++++----
 gio/gdbus-2.0/codegen/codegen_main.py |  2 ++
 2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gio/gdbus-2.0/codegen/codegen.py b/gio/gdbus-2.0/codegen/codegen.py
index d393f65cb..22559bd37 100644
--- a/gio/gdbus-2.0/codegen/codegen.py
+++ b/gio/gdbus-2.0/codegen/codegen.py
@@ -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'
diff --git a/gio/gdbus-2.0/codegen/codegen_main.py b/gio/gdbus-2.0/codegen/codegen_main.py
index 03de1d107..880ff3932 100644
--- a/gio/gdbus-2.0/codegen/codegen_main.py
+++ b/gio/gdbus-2.0/codegen/codegen_main.py
@@ -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()
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]