diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2014-05-27 14:02:12 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-05-28 12:39:00 +0200 |
commit | e1193a99b702296a6c5ab2496268712868eb91e0 (patch) | |
tree | 94735ae2c0a82aa929dbab23c8f53bea711f75ee /build-aux | |
parent | 8f8231fead42825847613a7ce7b0be2d79f19b92 (diff) |
qmi-codegen: handle 'gfloat' types
Diffstat (limited to 'build-aux')
-rw-r--r-- | build-aux/qmi-codegen/VariableFactory.py | 2 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableInteger.py | 17 | ||||
-rw-r--r-- | build-aux/qmi-codegen/utils.py | 9 |
3 files changed, 23 insertions, 5 deletions
diff --git a/build-aux/qmi-codegen/VariableFactory.py b/build-aux/qmi-codegen/VariableFactory.py index 48b1541..2b6004f 100644 --- a/build-aux/qmi-codegen/VariableFactory.py +++ b/build-aux/qmi-codegen/VariableFactory.py @@ -33,6 +33,8 @@ in the given dictionary def create_variable(dictionary, new_type_name, container_type): if utils.format_is_integer(dictionary['format']): return VariableInteger(dictionary) + elif utils.format_is_float(dictionary['format']): + return VariableInteger(dictionary) elif dictionary['format'] == 'string': return VariableString(dictionary) elif dictionary['format'] == 'struct': diff --git a/build-aux/qmi-codegen/VariableInteger.py b/build-aux/qmi-codegen/VariableInteger.py index 4fe58b7..235b552 100644 --- a/build-aux/qmi-codegen/VariableInteger.py +++ b/build-aux/qmi-codegen/VariableInteger.py @@ -23,8 +23,13 @@ import utils from Variable import Variable """ -Variable type for signed/unsigned Integers -('guint8', 'gint8', 'guint16', 'gint16', 'guint32', 'gint32', 'guint64', 'gint64' 'guint-sized' formats) +Variable type for signed/unsigned Integers and floating point numbers: + 'guint8', 'gint8' + 'guint16', 'gint16' + 'guint32', 'gint32' + 'guint64', 'gint64' + 'guint-sized' + 'gfloat' """ class VariableInteger(Variable): @@ -76,7 +81,7 @@ class VariableInteger(Variable): '${lp}qmi_utils_read_${private_format}_from_buffer (\n' '${lp} &${buffer_name},\n' '${lp} &${buffer_len},\n') - if self.private_format != 'guint8' and self.private_format != 'gint8': + if self.private_format != 'guint8' and self.private_format != 'gint8' and self.private_format != 'gfloat': template += ( '${lp} ${endian},\n') template += ( @@ -117,7 +122,7 @@ class VariableInteger(Variable): elif self.private_format == 'guint16' or self.private_format == 'gint16': template += ( '${lp}${variable_name} += 2;\n') - elif self.private_format == 'guint32' or self.private_format == 'gint32': + elif self.private_format == 'guint32' or self.private_format == 'gint32' or self.private_format == 'gfloat': template += ( '${lp}${variable_name} += 4;\n') elif self.private_format == 'guint64' or self.private_format == 'gint64': @@ -202,6 +207,8 @@ class VariableInteger(Variable): common_format = '%" G_GINT32_FORMAT "' elif self.private_format == 'gint64': common_format = '%" G_GINT64_FORMAT "' + elif self.private_format == 'gfloat': + common_format = '%f' translations = { 'lp' : line_prefix, 'private_format' : self.private_format, @@ -235,7 +242,7 @@ class VariableInteger(Variable): '${lp} qmi_utils_read_${private_format}_from_buffer (\n' '${lp} &${buffer_name},\n' '${lp} &${buffer_len},\n') - if self.private_format != 'guint8' and self.private_format != 'gint8': + if self.private_format != 'guint8' and self.private_format != 'gint8' and self.private_format != 'gfloat': template += ( '${lp} ${endian},\n') template += ( diff --git a/build-aux/qmi-codegen/utils.py b/build-aux/qmi-codegen/utils.py index 2d8e356..4b0f9ec 100644 --- a/build-aux/qmi-codegen/utils.py +++ b/build-aux/qmi-codegen/utils.py @@ -232,6 +232,15 @@ def format_is_signed_integer(fmt): else: return False +""" +Returns True if the given format corresponds to a basic floating point type +""" +def format_is_float(fmt): + if fmt == 'gfloat': + return True + else: + return False + """ Returns True if the given format corresponds to a basic signed or unsigned |