[glib: 3/4] gdbus-codegen: Tidy up version comparisons
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 3/4] gdbus-codegen: Tidy up version comparisons
- Date: Fri, 31 Jan 2020 13:49:54 +0000 (UTC)
commit 087b9829f486f54f174943c677a1580aed9d7b27
Author: Philip Withnall <withnall endlessm com>
Date: Fri Jan 31 12:23:22 2020 +0000
gdbus-codegen: Tidy up version comparisons
Python tuple comparisons actually do what we want for comparing major
and minor versions, so tidy things up by using that.
This introduces no functional changes.
Signed-off-by: Philip Withnall <withnall endlessm com>
gio/gdbus-2.0/codegen/codegen.py | 24 ++++++++----------------
gio/gdbus-2.0/codegen/codegen_main.py | 9 ++-------
2 files changed, 10 insertions(+), 23 deletions(-)
---
diff --git a/gio/gdbus-2.0/codegen/codegen.py b/gio/gdbus-2.0/codegen/codegen.py
index b778bffb5..d71299ebe 100644
--- a/gio/gdbus-2.0/codegen/codegen.py
+++ b/gio/gdbus-2.0/codegen/codegen.py
@@ -73,10 +73,6 @@ class HeaderCodeGenerator:
self.glib_min_required = glib_min_required
self.outfile = outfile
- self.glib_min_required_is_2_64 = (glib_min_required[0] > 2 or
- (glib_min_required[0] == 2 and
- glib_min_required[1] >= 64))
-
# ----------------------------------------------------------------------------------------------------
def generate_header_preamble(self):
@@ -226,7 +222,7 @@ class HeaderCodeGenerator:
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
for a in m.in_args:
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
- if self.glib_min_required_is_2_64:
+ if self.glib_min_required >= (2, 64):
self.outfile.write(',\n GDBusCallFlags call_flags'
',\n gint timeout_msec')
if m.unix_fd:
@@ -256,7 +252,7 @@ class HeaderCodeGenerator:
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
for a in m.in_args:
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
- if self.glib_min_required_is_2_64:
+ if self.glib_min_required >= (2, 64):
self.outfile.write(',\n GDBusCallFlags call_flags'
',\n gint timeout_msec')
if m.unix_fd:
@@ -926,10 +922,6 @@ class CodeGenerator:
self.glib_min_required = glib_min_required
self.outfile = outfile
- self.glib_min_required_is_2_64 = (glib_min_required[0] > 2 or
- (glib_min_required[0] == 2 and
- glib_min_required[1] >= 64))
-
# ----------------------------------------------------------------------------------------------------
def generate_body_preamble(self):
@@ -1680,7 +1672,7 @@ class CodeGenerator:
%(i.name_lower, m.name_lower, i.camel_name))
for a in m.in_args:
self.outfile.write(' * @arg_%s: Argument to pass with the method invocation.\n'%(a.name))
- if self.glib_min_required_is_2_64:
+ if self.glib_min_required >= (2, 64):
self.outfile.write(' * @call_flags: Flags from the #GDBusCallFlags enumeration. If you want
to allow interactive\n'
' authorization be sure to set
%G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION.\n'
' * @timeout_msec: The timeout in milliseconds (with %G_MAXINT meaning
"infinite") or\n'
@@ -1704,7 +1696,7 @@ class CodeGenerator:
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
for a in m.in_args:
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
- if self.glib_min_required_is_2_64:
+ if self.glib_min_required >= (2, 64):
self.outfile.write(',\n GDBusCallFlags call_flags'
',\n gint timeout_msec')
if m.unix_fd:
@@ -1726,7 +1718,7 @@ class CodeGenerator:
for a in m.in_args:
self.outfile.write(',\n arg_%s'%(a.name))
self.outfile.write('),\n')
- if self.glib_min_required_is_2_64:
+ if self.glib_min_required >= (2, 64):
self.outfile.write(' call_flags,\n'
' timeout_msec,\n')
else:
@@ -1797,7 +1789,7 @@ class CodeGenerator:
%(i.name_lower, m.name_lower, i.camel_name))
for a in m.in_args:
self.outfile.write(' * @arg_%s: Argument to pass with the method invocation.\n'%(a.name))
- if self.glib_min_required_is_2_64:
+ if self.glib_min_required >= (2, 64):
self.outfile.write(' * @call_flags: Flags from the #GDBusCallFlags enumeration. If you want
to allow interactive\n'
' authorization be sure to set
%G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION.\n'
' * @timeout_msec: The timeout in milliseconds (with %G_MAXINT meaning
"infinite") or\n'
@@ -1824,7 +1816,7 @@ class CodeGenerator:
' %s *proxy'%(i.name_lower, m.name_lower, i.camel_name))
for a in m.in_args:
self.outfile.write(',\n %sarg_%s'%(a.ctype_in, a.name))
- if self.glib_min_required_is_2_64:
+ if self.glib_min_required >= (2, 64):
self.outfile.write(',\n GDBusCallFlags call_flags'
',\n gint timeout_msec')
if m.unix_fd:
@@ -1850,7 +1842,7 @@ class CodeGenerator:
for a in m.in_args:
self.outfile.write(',\n arg_%s'%(a.name))
self.outfile.write('),\n')
- if self.glib_min_required_is_2_64:
+ if self.glib_min_required >= (2, 64):
self.outfile.write(' call_flags,\n'
' timeout_msec,\n')
else:
diff --git a/gio/gdbus-2.0/codegen/codegen_main.py b/gio/gdbus-2.0/codegen/codegen_main.py
index c938640e7..75d97e3c7 100644
--- a/gio/gdbus-2.0/codegen/codegen_main.py
+++ b/gio/gdbus-2.0/codegen/codegen_main.py
@@ -251,8 +251,7 @@ def codegen_main():
print_error('Unrecognized --glib-min-required string ‘{}’'.format(
args.glib_min_required))
- if glib_min_required[0] < 2 or \
- (glib_min_required[0] == 2 and glib_min_required[1] < 30):
+ if glib_min_required < (2, 30):
print_error('Invalid --glib-min-required string ‘{}’: minimum '
'version is 2.30'.format(args.glib_min_required))
else:
@@ -280,17 +279,13 @@ def codegen_main():
print_error('Invalid versions: --glib-min-required ({}) must be '
'less than or equal to --glib-max-allowed ({})'.format(glib_min_required,
glib_max_allowed))
- glib_min_required_is_2_64 = (glib_min_required[0] > 2 or
- (glib_min_required[0] == 2 and
- glib_min_required[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,
- h_type_implies_unix_fd=glib_min_required_is_2_64)
+ h_type_implies_unix_fd=(glib_min_required >= (2, 64)))
all_ifaces.extend(parsed_ifaces)
input_files_basenames.append(os.path.basename(fname))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]