gdbus-codegen: Emit GUnixFDLists if an arg has type h w/ min-version

This is a reimplementation of commit
4aba03562b from Will Thompson, but
conditional on the caller passing `--glib-min-version 2.64` to
`gdbus-codegen` to explicitly opt-in to the new behaviour.

From the commit message for that commit:

Previously, if a method was not annotated with org.gtk.GDBus.C.UnixFD
then the generated code would never contain GUnixFDList parameters, even
if the method has 'h' (file descriptor) parameters. However, in this
case, the generated code is essentially useless: the method cannot be
called or handled except in degenerate cases where the file descriptors
are missing or ignored.

Check the argument types for 'h', and if present, generate code as if
org.gtk.GDBus.C.UnixFD annotation were specified.

Includes a unit test too.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1726
This commit is contained in:
Philip Withnall
2019-12-02 16:20:16 +00:00
parent 90f0733858
commit e3f80b9254
4 changed files with 69 additions and 6 deletions

View File

@@ -256,12 +256,17 @@ def codegen_main():
else:
glib_min_version = (2, 30)
glib_min_version_is_2_64 = (glib_min_version[0] > 2 or
(glib_min_version[0] == 2 and
glib_min_version[1] >= 64))
all_ifaces = []
input_files_basenames = []
for fname in sorted(args.files + args.xml_files):
with open(fname, 'rb') as f:
xml_data = f.read()
parsed_ifaces = parser.parse_dbus_xml(xml_data)
parsed_ifaces = parser.parse_dbus_xml(xml_data,
h_type_implies_unix_fd=glib_min_version_is_2_64)
all_ifaces.extend(parsed_ifaces)
input_files_basenames.append(os.path.basename(fname))