diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2022-02-23 12:39:28 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2022-02-26 23:16:11 +0100 |
commit | ba583f223a483106af16b45077ec6f9b5a3e52dd (patch) | |
tree | 105f831b46bde5dc2ab01f86b1313177f9e6308f /build-aux | |
parent | d6ea16dac905a916bb79992533056c682659556f (diff) | |
download | libqmi-ba583f223a483106af16b45077ec6f9b5a3e52dd.tar.gz |
build-aux,codegen: 'to' is always reference in getter implementation
Diffstat (limited to 'build-aux')
-rw-r--r-- | build-aux/qmi-codegen/Field.py | 2 | ||||
-rw-r--r-- | build-aux/qmi-codegen/Variable.py | 2 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableArray.py | 12 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableInteger.py | 15 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableSequence.py | 5 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableString.py | 15 |
6 files changed, 18 insertions, 33 deletions
diff --git a/build-aux/qmi-codegen/Field.py b/build-aux/qmi-codegen/Field.py index bdbb04e7..cdff8722 100644 --- a/build-aux/qmi-codegen/Field.py +++ b/build-aux/qmi-codegen/Field.py @@ -117,7 +117,7 @@ class Field: input_variable_name = 'value_' + utils.build_underscore_name(self.name) variable_getter_dec = self.variable.build_getter_declaration(' ', input_variable_name) variable_getter_doc = self.variable.build_getter_documentation(' * ', input_variable_name) - variable_getter_imp = self.variable.build_getter_implementation(' ', 'self->' + self.variable_name, input_variable_name, True) + variable_getter_imp = self.variable.build_getter_implementation(' ', 'self->' + self.variable_name, input_variable_name) translations = { 'name' : self.name, 'variable_name' : self.variable_name, 'variable_getter_dec' : variable_getter_dec, diff --git a/build-aux/qmi-codegen/Variable.py b/build-aux/qmi-codegen/Variable.py index 7eb819f8..7eb803f0 100644 --- a/build-aux/qmi-codegen/Variable.py +++ b/build-aux/qmi-codegen/Variable.py @@ -131,7 +131,7 @@ class Variable: """ Builds the code to implement getting this kind of variable. """ - def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to, to_is_reference): + def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to): return '' """ diff --git a/build-aux/qmi-codegen/VariableArray.py b/build-aux/qmi-codegen/VariableArray.py index d2fd803c..cb117c1d 100644 --- a/build-aux/qmi-codegen/VariableArray.py +++ b/build-aux/qmi-codegen/VariableArray.py @@ -391,7 +391,7 @@ class VariableArray(Variable): """ Builds the array getter implementation """ - def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to, to_is_reference): + def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to): if not self.visible: return "" @@ -405,13 +405,9 @@ class VariableArray(Variable): '${lp}if (${to}_sequence)\n' '${lp} *${to}_sequence = ${from}_sequence;\n') - if to_is_reference: - template += ( - '${lp}if (${to})\n' - '${lp} *${to} = ${from};\n') - else: - template += ( - '${lp}${to} = ${from};\n') + template += ( + '${lp}if (${to})\n' + '${lp} *${to} = ${from};\n') return string.Template(template).substitute(translations) diff --git a/build-aux/qmi-codegen/VariableInteger.py b/build-aux/qmi-codegen/VariableInteger.py index 5f077540..8640ee9a 100644 --- a/build-aux/qmi-codegen/VariableInteger.py +++ b/build-aux/qmi-codegen/VariableInteger.py @@ -304,7 +304,7 @@ class VariableInteger(Variable): """ Builds the Integer getter implementation """ - def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to, to_is_reference): + def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to): if not self.visible: return "" @@ -315,15 +315,10 @@ class VariableInteger(Variable): 'cast_ini' : '(' + self.public_format + ')(' if needs_cast else '', 'cast_end' : ')' if needs_cast else '' } - if to_is_reference: - template = ( - '${lp}if (${to})\n' - '${lp} *${to} = ${cast_ini}${from}${cast_end};\n') - return string.Template(template).substitute(translations) - else: - template = ( - '${lp}${to} = ${cast_ini}${from}${cast_end};\n') - return string.Template(template).substitute(translations) + template = ( + '${lp}if (${to})\n' + '${lp} *${to} = ${cast_ini}${from}${cast_end};\n') + return string.Template(template).substitute(translations) """ diff --git a/build-aux/qmi-codegen/VariableSequence.py b/build-aux/qmi-codegen/VariableSequence.py index 46b72d85..704a8515 100644 --- a/build-aux/qmi-codegen/VariableSequence.py +++ b/build-aux/qmi-codegen/VariableSequence.py @@ -157,7 +157,7 @@ class VariableSequence(Variable): """ Builds the Struct getter implementation """ - def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to, to_is_reference): + def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to): if not self.visible: return "" @@ -165,8 +165,7 @@ class VariableSequence(Variable): for member in self.members: built += member['object'].build_getter_implementation(line_prefix, variable_name_from + '_' + member['name'], - variable_name_to + '_' + member['name'], - to_is_reference) + variable_name_to + '_' + member['name']) return built diff --git a/build-aux/qmi-codegen/VariableString.py b/build-aux/qmi-codegen/VariableString.py index 2380f315..48d6d6b7 100644 --- a/build-aux/qmi-codegen/VariableString.py +++ b/build-aux/qmi-codegen/VariableString.py @@ -221,7 +221,7 @@ class VariableString(Variable): """ Builds the String getter implementation """ - def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to, to_is_reference): + def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to): if not self.visible: return "" @@ -229,15 +229,10 @@ class VariableString(Variable): 'from' : variable_name_from, 'to' : variable_name_to } - if to_is_reference: - template = ( - '${lp}if (${to})\n' - '${lp} *${to} = ${from};\n') - return string.Template(template).substitute(translations) - else: - template = ( - '${lp}${to} = ${from};\n') - return string.Template(template).substitute(translations) + template = ( + '${lp}if (${to})\n' + '${lp} *${to} = ${from};\n') + return string.Template(template).substitute(translations) """ |