diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-23 12:19:04 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-23 12:20:25 +0200 |
commit | 75f3c85b100e4565dab08c3f8d58defa42f75e2c (patch) | |
tree | 764af3c3685d6641c8f4fc5378fea2945ac7931e /build-aux | |
parent | a6bee847c72a643aa4e6fcc7ee218fbb863b5cf4 (diff) | |
download | external_libqmi-75f3c85b100e4565dab08c3f8d58defa42f75e2c.zip external_libqmi-75f3c85b100e4565dab08c3f8d58defa42f75e2c.tar.gz external_libqmi-75f3c85b100e4565dab08c3f8d58defa42f75e2c.tar.bz2 |
qmi-codegen: support a new 'version' tag in the messages
If the 'version' tag is given in the messages and the `QmiDevice' is opened with
a explicit version info check, we will return an error if we're trying to send
a message which was introduced in a newer version of a service we support.
Diffstat (limited to 'build-aux')
-rw-r--r-- | build-aux/qmi-codegen/Message.py | 2 | ||||
-rw-r--r-- | build-aux/qmi-codegen/MessageList.py | 47 |
2 files changed, 49 insertions, 0 deletions
diff --git a/build-aux/qmi-codegen/Message.py b/build-aux/qmi-codegen/Message.py index 3f74c70..199b57d 100644 --- a/build-aux/qmi-codegen/Message.py +++ b/build-aux/qmi-codegen/Message.py @@ -42,6 +42,8 @@ class Message: self.id = dictionary['id'] # The type, which must always be 'Message' self.type = dictionary['type'] + # The version info, optional + self.version_info = dictionary['version'].split('.') if 'version' in dictionary else [] # Create the composed full name (prefix + service + name), # e.g. "Qmi Message Ctl Something Output Result" diff --git a/build-aux/qmi-codegen/MessageList.py b/build-aux/qmi-codegen/MessageList.py index b00df7b..a610a31 100644 --- a/build-aux/qmi-codegen/MessageList.py +++ b/build-aux/qmi-codegen/MessageList.py @@ -119,6 +119,52 @@ class MessageList: """ + Emit the method responsible for getting in which version the messages were + introduced. + """ + def __emit_get_version_introduced(self, hfile, cfile): + translations = { 'service' : string.lower(self.service) } + + template = ( + '\n' + 'gboolean qmi_message_${service}_get_version_introduced (\n' + ' QmiMessage *self,\n' + ' guint *major,\n' + ' guint *minor);\n') + hfile.write(string.Template(template).substitute(translations)) + + template = ( + '\n' + 'gboolean\n' + 'qmi_message_${service}_get_version_introduced (\n' + ' QmiMessage *self,\n' + ' guint *major,\n' + ' guint *minor)\n' + '{\n' + ' switch (qmi_message_get_message_id (self)) {\n') + + for message in self.list: + # Only add if we know the version info + if message.version_info != []: + translations['enum_name'] = message.id_enum_name + translations['message_major'] = message.version_info[0] + translations['message_minor'] = message.version_info[1] + inner_template = ( + ' case ${enum_name}:\n' + ' *major = ${message_major};\n' + ' *minor = ${message_minor};\n' + ' return TRUE;\n') + template += string.Template(inner_template).substitute(translations) + + template += ( + ' default:\n' + ' return FALSE;\n' + ' }\n' + '}\n') + cfile.write(string.Template(template).substitute(translations)) + + + """ Emit the message list handling implementation """ def emit(self, hfile, cfile): @@ -133,3 +179,4 @@ class MessageList: utils.add_separator(hfile, 'Service-specific printable', self.service); utils.add_separator(cfile, 'Service-specific printable', self.service); self.__emit_get_printable(hfile, cfile) + self.__emit_get_version_introduced(hfile, cfile) |