aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-07-04 12:02:15 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-07-04 12:02:15 +0200
commit03aa6bc53c7873633be7f52669636004c4cf0373 (patch)
treeac2d2186dc727076e3e19745c41f4f711f4f03a5 /build-aux
parentcb6985816bdafc40fee6d57c6320e18906990ba7 (diff)
qmi-codegen: handle 64-bit signed/unsigned integers
Diffstat (limited to 'build-aux')
-rw-r--r--build-aux/qmi-codegen/VariableInteger.py29
-rw-r--r--build-aux/qmi-codegen/utils.py6
2 files changed, 25 insertions, 10 deletions
diff --git a/build-aux/qmi-codegen/VariableInteger.py b/build-aux/qmi-codegen/VariableInteger.py
index 9705e3d..5c28933 100644
--- a/build-aux/qmi-codegen/VariableInteger.py
+++ b/build-aux/qmi-codegen/VariableInteger.py
@@ -24,7 +24,7 @@ from Variable import Variable
"""
Variable type for signed/unsigned Integers
-('guint8', 'gint8', 'guint16', 'gint16', 'guint32', 'gint32' formats)
+('guint8', 'gint8', 'guint16', 'gint16', 'guint32', 'gint32', 'guint64', 'gint64' formats)
"""
class VariableInteger(Variable):
@@ -105,16 +105,29 @@ class VariableInteger(Variable):
"""
- Get the integer as a printable string. Given that we support max 32-bit
- integers, it is safe to cast all them to standard integers when printing.
+ Get the integer as a printable string.
"""
def emit_get_printable(self, f, line_prefix, printable, buffer_name, buffer_len):
- if utils.format_is_unsigned_integer(self.private_format):
+ common_format = ''
+ common_cast = ''
+ if self.private_format == 'guint8':
common_format = '%u'
- common_cast = 'guint'
- else:
+ common_cast = '(guint)'
+ elif self.private_format == 'guint16':
+ common_format = '%" G_GUINT16_FORMAT "'
+ elif self.private_format == 'guint32':
+ common_format = '%" G_GUINT32_FORMAT "'
+ elif self.private_format == 'guint64':
+ common_format = '%" G_GUINT64_FORMAT "'
+ elif self.private_format == 'gint8':
common_format = '%d'
- common_cast = 'gint'
+ common_cast = '(gint)'
+ elif self.private_format == 'gint16':
+ common_format = '%" G_GINT16_FORMAT "'
+ elif self.private_format == 'gint32':
+ common_format = '%" G_GINT32_FORMAT "'
+ elif self.private_format == 'gint64':
+ common_format = '%" G_GINT64_FORMAT "'
translations = { 'lp' : line_prefix,
'private_format' : self.private_format,
@@ -135,7 +148,7 @@ class VariableInteger(Variable):
'${lp} &${buffer_len},\n'
'${lp} &tmp);\n'
'\n'
- '${lp} g_string_append_printf (${printable}, "${common_format}", (${common_cast})tmp);\n'
+ '${lp} g_string_append_printf (${printable}, "${common_format}", ${common_cast}tmp);\n'
'${lp}}\n')
f.write(string.Template(template).substitute(translations))
diff --git a/build-aux/qmi-codegen/utils.py b/build-aux/qmi-codegen/utils.py
index a6e2363..239e03b 100644
--- a/build-aux/qmi-codegen/utils.py
+++ b/build-aux/qmi-codegen/utils.py
@@ -171,7 +171,8 @@ Returns True if the given format corresponds to a basic unsigned integer type
def format_is_unsigned_integer(fmt):
if fmt == 'guint8' or \
fmt == 'guint16' or \
- fmt == 'guint32':
+ fmt == 'guint32' or \
+ fmt == 'guint64':
return True
else:
return False
@@ -183,7 +184,8 @@ Returns True if the given format corresponds to a basic signed integer type
def format_is_signed_integer(fmt):
if fmt == 'gint8' or \
fmt == 'gint16' or \
- fmt == 'gint32':
+ fmt == 'gint32' or \
+ fmt == 'gint64':
return True
else:
return False