diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-05-22 16:57:09 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-03 16:08:54 +0200 |
commit | 758992dc0a31f81c54f91b883db5c6c06155a8e0 (patch) | |
tree | 65700ff324fdd89aceffa1ceaf9002e92e30f5cc /build-aux/qmi-codegen | |
parent | de514133cec8d12906f19c868542b7530058a0c1 (diff) | |
download | external_libqmi-758992dc0a31f81c54f91b883db5c6c06155a8e0.zip external_libqmi-758992dc0a31f81c54f91b883db5c6c06155a8e0.tar.gz external_libqmi-758992dc0a31f81c54f91b883db5c6c06155a8e0.tar.bz2 |
qmi-codegen: `prerequisites' will always be a list of dicts
Diffstat (limited to 'build-aux/qmi-codegen')
-rw-r--r-- | build-aux/qmi-codegen/Container.py | 2 | ||||
-rw-r--r-- | build-aux/qmi-codegen/Field.py | 38 |
2 files changed, 17 insertions, 23 deletions
diff --git a/build-aux/qmi-codegen/Container.py b/build-aux/qmi-codegen/Container.py index fe81c28..adfa2a7 100644 --- a/build-aux/qmi-codegen/Container.py +++ b/build-aux/qmi-codegen/Container.py @@ -68,7 +68,7 @@ class Container: # support complex setups yet. sorted_dictionary = [] for field_dictionary in dictionary: - if 'prerequisite' in field_dictionary: + if 'prerequisites' in field_dictionary: sorted_dictionary.append(field_dictionary) else: sorted_dictionary.insert(0, field_dictionary) diff --git a/build-aux/qmi-codegen/Field.py b/build-aux/qmi-codegen/Field.py index a644747..ab7afe9 100644 --- a/build-aux/qmi-codegen/Field.py +++ b/build-aux/qmi-codegen/Field.py @@ -43,7 +43,9 @@ class Field: # The type, which must always be "TLV" self.type = dictionary['type'] # Output Fields may have prerequisites - self.prerequisite = dictionary['prerequisite'] if 'prerequisite' in dictionary else None + self.prerequisites = [] + if 'prerequisites' in dictionary: + self.prerequisites = dictionary['prerequisites'] # Strings containing how the given type is to be copied and disposed self.copy = None @@ -181,29 +183,21 @@ class Field: pass - def __emit_single_prerequisite_check(self, f, line_prefix, prerequisite): - translations = { 'lp' : line_prefix, - 'prerequisite_field' : utils.build_underscore_name(prerequisite['field']), - 'prerequisite_operation' : prerequisite['operation'], - 'prerequisite_value' : prerequisite['value'] } - template = ( - '${lp}/* Prerequisite.... */\n' - '${lp}if (!(self->arg_${prerequisite_field} ${prerequisite_operation} ${prerequisite_value}))\n' - '${lp} break;\n') - f.write(string.Template(template).substitute(translations)) - - def emit_output_prerequisite_check(self, f, line_prefix): - if self.prerequisite is not None: - # We may have a single prerequisite or a list of prerequisites - if isinstance(self.prerequisite, dict): - self.__emit_single_prerequisite_check(f, line_prefix, self.prerequisite) - else: - for prerequisite in self.prerequisite: - self.__emit_single_prerequisite_check(f, line_prefix, prerequisite) - else: + if self.prerequisites == []: f.write('%s/* No Prerequisites for field */\n' % line_prefix) - + return + + for prerequisite in self.prerequisites: + translations = { 'lp' : line_prefix, + 'prerequisite_field' : utils.build_underscore_name(prerequisite['field']), + 'prerequisite_operation' : prerequisite['operation'], + 'prerequisite_value' : prerequisite['value'] } + template = ( + '${lp}/* Prerequisite.... */\n' + '${lp}if (!(self->arg_${prerequisite_field} ${prerequisite_operation} ${prerequisite_value}))\n' + '${lp} break;\n') + f.write(string.Template(template).substitute(translations)) def emit_output_tlv_get(self, f, line_prefix): ''' |