summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-09-03 21:25:30 -0500
committerAleksander Morgado <aleksander@lanedo.com>2012-09-08 10:34:13 +0200
commitba4e131c896d35e075f00c15e424a7085e967f80 (patch)
treedb42cfbf2e595c85b27d7d9aa2b14c3a6a1066a4
parente6f08631b764fa893d6f1c1aaaa795111c5d2652 (diff)
qmi-codegen: handle string arrays
Like these: struct { uint8 num_instances; struct { uint8 length; char data[]; }; };
-rw-r--r--build-aux/qmi-codegen/VariableArray.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/build-aux/qmi-codegen/VariableArray.py b/build-aux/qmi-codegen/VariableArray.py
index f7fc0ef..4911111 100644
--- a/build-aux/qmi-codegen/VariableArray.py
+++ b/build-aux/qmi-codegen/VariableArray.py
@@ -39,6 +39,7 @@ class VariableArray(Variable):
self.private_format = 'GArray *'
self.public_format = self.private_format
self.fixed_size = 0
+ self.name = dictionary['name']
# The array and its contents need to get disposed
self.needs_dispose = True
@@ -74,6 +75,18 @@ class VariableArray(Variable):
"""
+ Constructs the name of the array clear function
+ """
+ def clear_func_name(self):
+ # element public format might be a base type like 'gchar *' rather
+ # than a structure name like QmiFooBar
+ elt_name = string.replace(self.array_element.public_format, '*', 'pointer')
+ return utils.build_underscore_name(self.name) + \
+ '_' + \
+ utils.build_underscore_name_from_camelcase(utils.build_camelcase_name(elt_name))
+
+
+ """
Emits the code to clear the element of the array
"""
def emit_helper_methods(self, hfile, cfile):
@@ -82,7 +95,7 @@ class VariableArray(Variable):
return
translations = { 'element_format' : self.array_element.public_format,
- 'underscore' : utils.build_underscore_name_from_camelcase(self.array_element.public_format),
+ 'underscore' : self.clear_func_name(),
'dispose_contents' : self.array_element.build_dispose(' ', '(*p)') }
template = (
@@ -103,7 +116,7 @@ class VariableArray(Variable):
translations = { 'lp' : line_prefix,
'private_format' : self.private_format,
'public_array_element_format' : self.array_element.public_format,
- 'underscore' : utils.build_underscore_name_from_camelcase(self.array_element.public_format),
+ 'underscore' : self.clear_func_name(),
'variable_name' : variable_name,
'buffer_name' : buffer_name,
'buffer_len' : buffer_len }