aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux/qmi-codegen/VariableArray.py
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-09-25 14:41:37 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-09-26 09:45:42 +0200
commitc4a85b1f960247d2f614975d182049d010b36eb3 (patch)
treee48d589aaece8aaa8680fcffd61c74432163e6c7 /build-aux/qmi-codegen/VariableArray.py
parenta336eca159f3c8c9b7f2f65c05c9adefb2617322 (diff)
downloadexternal_libqmi-c4a85b1f960247d2f614975d182049d010b36eb3.zip
external_libqmi-c4a85b1f960247d2f614975d182049d010b36eb3.tar.gz
external_libqmi-c4a85b1f960247d2f614975d182049d010b36eb3.tar.bz2
qmi-codegen: don't issue the array element clear function on 'Input' arrays
When an array is required to be passed in an input TLV, the user who created it is responsible for freeing it. Therefore, we should not dump the static array element clear function in these cases, or these unused methods will end up breaking the compilation.
Diffstat (limited to 'build-aux/qmi-codegen/VariableArray.py')
-rw-r--r--build-aux/qmi-codegen/VariableArray.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/build-aux/qmi-codegen/VariableArray.py b/build-aux/qmi-codegen/VariableArray.py
index 47ff6ff..f5bc65f 100644
--- a/build-aux/qmi-codegen/VariableArray.py
+++ b/build-aux/qmi-codegen/VariableArray.py
@@ -31,7 +31,7 @@ class VariableArray(Variable):
"""
Constructor
"""
- def __init__(self, dictionary, array_element_type):
+ def __init__(self, dictionary, array_element_type, container_type):
# Call the parent constructor
Variable.__init__(self, dictionary)
@@ -44,11 +44,16 @@ class VariableArray(Variable):
# The array and its contents need to get disposed
self.needs_dispose = True
+ # We need to know whether the variable comes in an Input container or in
+ # an Output container, as we should not dump the element clear() helper method
+ # if the variable is from an Input container.
+ self.container_type = container_type
+
# Load variable type of this array
if 'name' in dictionary['array-element']:
- self.array_element = VariableFactory.create_variable(dictionary['array-element'], array_element_type + ' ' + dictionary['array-element']['name'])
+ self.array_element = VariableFactory.create_variable(dictionary['array-element'], array_element_type + ' ' + dictionary['array-element']['name'], self.container_type)
else:
- self.array_element = VariableFactory.create_variable(dictionary['array-element'], '')
+ self.array_element = VariableFactory.create_variable(dictionary['array-element'], '', self.container_type)
# Load variable type for the array size prefix
if 'size-prefix-format' in dictionary:
@@ -56,7 +61,7 @@ class VariableArray(Variable):
if dictionary['size-prefix-format'] not in [ 'guint8', 'guint16', 'guint32' ]:
raise ValueError('Invalid size prefix format (%s): not guint8 or guint16 or guint32' % dictionary['size-prefix-format'])
default_array_size = { 'format' : dictionary['size-prefix-format'] }
- self.array_size_element = VariableFactory.create_variable(default_array_size, '')
+ self.array_size_element = VariableFactory.create_variable(default_array_size, '', self.container_type)
elif 'fixed-size' in dictionary:
# fixed-size arrays have no size element, obviously
self.fixed_size = dictionary['fixed-size']
@@ -65,7 +70,7 @@ class VariableArray(Variable):
else:
# Default to 'guint8' if no explicit array size given
default_array_size = { 'format' : 'guint8' }
- self.array_size_element = VariableFactory.create_variable(default_array_size, '')
+ self.array_size_element = VariableFactory.create_variable(default_array_size, '', self.container_type)
"""
@@ -97,6 +102,11 @@ class VariableArray(Variable):
if self.array_element.needs_dispose == False:
return
+ # No need for the clear func if we were not the ones who created
+ # the array
+ if self.container_type == "Input":
+ return
+
translations = { 'element_format' : self.array_element.public_format,
'underscore' : self.clear_func_name(),
'dispose_contents' : self.array_element.build_dispose(' ', '(*p)') }