diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-05-23 17:49:30 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-03 16:08:55 +0200 |
commit | 09a84b18211a06324d1075e1c59e98ad9c196abe (patch) | |
tree | 8f34c5dcd6918a58f11eb9c3b0711a2edcc9a7e5 /build-aux | |
parent | b9beb566171a7024b32e1d76477580171dec3929 (diff) |
qmi-codegen: include integer TLV contents in printable strings
Diffstat (limited to 'build-aux')
-rw-r--r-- | build-aux/qmi-codegen/FieldBasic.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/build-aux/qmi-codegen/FieldBasic.py b/build-aux/qmi-codegen/FieldBasic.py index dad34bf..ca8dea7 100644 --- a/build-aux/qmi-codegen/FieldBasic.py +++ b/build-aux/qmi-codegen/FieldBasic.py @@ -96,3 +96,41 @@ class FieldBasic(Field): template = ( '${lp}}\n') cfile.write(string.Template(template).substitute(translations)) + + + def emit_output_tlv_get_printable(self, f): + translations = { 'underscore' : utils.build_underscore_name (self.fullname), + 'field_type' : self.field_type, + 'tlv_id' : self.id_enum_name } + + template = ( + '\n' + 'static gchar *\n' + '${underscore}_get_printable (\n' + ' QmiMessage *self)\n' + '{\n' + ' ${field_type} tmp;\n' + ' gchar *printable;\n' + '\n' + ' g_assert (qmi_message_tlv_get (self,\n' + ' ${tlv_id},\n' + ' sizeof (tmp),\n' + ' &tmp,\n' + ' NULL));\n') + + template += (' %s;\n' % (utils.le_from_he('tmp', 'tmp', self.field_type))) + + if self.format == 'guint8' or \ + self.format == 'guint16' or \ + self.format == 'guin32': + template += ( + ' printable = g_strdup_printf ("%u", (guint)tmp);\n') + else: + template += ( + ' printable = g_strdup_printf ("%d", (gint)tmp);\n') + + template += ( + '\n' + ' return printable;\n' + '}\n') + f.write(string.Template(template).substitute(translations)) |