diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2014-12-12 09:21:15 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-12-12 09:21:15 +0100 |
commit | b9c3701e3371984736240d2dded70c2d52f3b46e (patch) | |
tree | d70ad25a58d5a923225febd6e0786ee55119a07f | |
parent | 3853840a31906b50051f20146e669d85f3e46903 (diff) | |
download | external_libqmi-b9c3701e3371984736240d2dded70c2d52f3b46e.zip external_libqmi-b9c3701e3371984736240d2dded70c2d52f3b46e.tar.gz external_libqmi-b9c3701e3371984736240d2dded70c2d52f3b46e.tar.bz2 |
qmi-codegen: fix public struct type generation
This change triggers an API break.
When building structs to be included in the public header, we were just relying
on using the 'public_format' of each variable. This is an error, as the variable
may be more complex than just public/private. E.g. could be another struct, or
an array, or a fixed sized string, as in the example.
In particular, this bug currently affects one public type, where one of its
elements changes from being just a pointer to a string to a fixed sized array of
4 bytes.
The following type is changed from:
typedef struct _QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement {
guint32 cell_id;
gchar * plmn;
guint16 lac;
guint16 geran_absolute_rf_channel_number;
guint8 base_station_identity_code;
guint16 rx_level;
} QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement;
To:
typedef struct _QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement {
guint32 cell_id;
gchar plmn[4];
guint16 lac;
guint16 geran_absolute_rf_channel_number;
guint8 base_station_identity_code;
guint16 rx_level;
} QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement;
Thanks to Joseba Sanjuan <joseba.sanjuan@gmail.com> for finding the bug.
-rw-r--r-- | build-aux/qmi-codegen/Container.py | 2 | ||||
-rw-r--r-- | build-aux/qmi-codegen/Variable.py | 2 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableArray.py | 2 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableInteger.py | 13 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableSequence.py | 4 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableString.py | 2 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableStruct.py | 8 |
7 files changed, 17 insertions, 16 deletions
diff --git a/build-aux/qmi-codegen/Container.py b/build-aux/qmi-codegen/Container.py index d7488f1..d79722b 100644 --- a/build-aux/qmi-codegen/Container.py +++ b/build-aux/qmi-codegen/Container.py @@ -140,7 +140,7 @@ class Container: if self.fields is not None: for field in self.fields: if field.variable is not None: - variable_declaration = field.variable.build_variable_declaration(' ', field.variable_name) + variable_declaration = field.variable.build_variable_declaration(False, ' ', field.variable_name) translations['field_variable_name'] = field.variable_name translations['field_name'] = field.name template = ( diff --git a/build-aux/qmi-codegen/Variable.py b/build-aux/qmi-codegen/Variable.py index cc992c6..d3691a3 100644 --- a/build-aux/qmi-codegen/Variable.py +++ b/build-aux/qmi-codegen/Variable.py @@ -94,7 +94,7 @@ class Variable: """ Builds the code to include the declaration of a variable of this kind. """ - def build_variable_declaration(self, line_prefix, variable_name): + def build_variable_declaration(self, public, line_prefix, variable_name): return '' """ diff --git a/build-aux/qmi-codegen/VariableArray.py b/build-aux/qmi-codegen/VariableArray.py index b1c8110..a00fae5 100644 --- a/build-aux/qmi-codegen/VariableArray.py +++ b/build-aux/qmi-codegen/VariableArray.py @@ -325,7 +325,7 @@ class VariableArray(Variable): """ Variable declaration """ - def build_variable_declaration(self, line_prefix, variable_name): + def build_variable_declaration(self, public, line_prefix, variable_name): translations = { 'lp' : line_prefix, 'name' : variable_name } diff --git a/build-aux/qmi-codegen/VariableInteger.py b/build-aux/qmi-codegen/VariableInteger.py index 44a0761..060548d 100644 --- a/build-aux/qmi-codegen/VariableInteger.py +++ b/build-aux/qmi-codegen/VariableInteger.py @@ -245,13 +245,18 @@ class VariableInteger(Variable): """ Variable declaration """ - def build_variable_declaration(self, line_prefix, variable_name): + def build_variable_declaration(self, public, line_prefix, variable_name): translations = { 'lp' : line_prefix, 'private_format' : self.private_format, + 'public_format' : self.public_format, 'name' : variable_name } - - template = ( - '${lp}${private_format} ${name};\n') + template = '' + if public: + template += ( + '${lp}${public_format} ${name};\n') + else: + template += ( + '${lp}${private_format} ${name};\n') return string.Template(template).substitute(translations) diff --git a/build-aux/qmi-codegen/VariableSequence.py b/build-aux/qmi-codegen/VariableSequence.py index c69a0e6..e0d2e00 100644 --- a/build-aux/qmi-codegen/VariableSequence.py +++ b/build-aux/qmi-codegen/VariableSequence.py @@ -120,10 +120,10 @@ class VariableSequence(Variable): """ Variable declaration """ - def build_variable_declaration(self, line_prefix, variable_name): + def build_variable_declaration(self, public, line_prefix, variable_name): built = '' for member in self.members: - built += member['object'].build_variable_declaration(line_prefix, variable_name + '_' + member['name']) + built += member['object'].build_variable_declaration(public, line_prefix, variable_name + '_' + member['name']) return built diff --git a/build-aux/qmi-codegen/VariableString.py b/build-aux/qmi-codegen/VariableString.py index 355fe4a..f7e1dcb 100644 --- a/build-aux/qmi-codegen/VariableString.py +++ b/build-aux/qmi-codegen/VariableString.py @@ -152,7 +152,7 @@ class VariableString(Variable): """ Variable declaration """ - def build_variable_declaration(self, line_prefix, variable_name): + def build_variable_declaration(self, public, line_prefix, variable_name): translations = { 'lp' : line_prefix, 'name' : variable_name } diff --git a/build-aux/qmi-codegen/VariableStruct.py b/build-aux/qmi-codegen/VariableStruct.py index b19b4c6..445af71 100644 --- a/build-aux/qmi-codegen/VariableStruct.py +++ b/build-aux/qmi-codegen/VariableStruct.py @@ -81,11 +81,7 @@ class VariableStruct(Variable): f.write(string.Template(template).substitute(translations)) for member in self.members: - translations['variable_format'] = member['object'].public_format - translations['variable_name'] = member['name'] - template = ( - ' ${variable_format} ${variable_name};\n') - f.write(string.Template(template).substitute(translations)) + f.write(member['object'].build_variable_declaration(True, ' ', member['name'])) template = ('} ${format};\n') f.write(string.Template(template).substitute(translations)) @@ -149,7 +145,7 @@ class VariableStruct(Variable): """ Variable declaration """ - def build_variable_declaration(self, line_prefix, variable_name): + def build_variable_declaration(self, public, line_prefix, variable_name): translations = { 'lp' : line_prefix, 'format' : self.public_format, 'name' : variable_name } |