qmi-codegen: allow fields to be hidden with 'visible':'no'

We want to mark some TLV fields as reserved and not exposed through the
public API due to alignment or other issues.
This commit is contained in:
Dan Williams 2016-10-05 23:05:04 -05:00
parent 4c678418f3
commit e2f9d3d591
6 changed files with 95 additions and 0 deletions

View File

@ -40,6 +40,11 @@ class Variable:
self.public_format = None
self.private_format = None
"""
Whether the variable is visible in public API or is reserved
"""
self.visible = False if ('visible' in dictionary and dictionary['visible'] == 'no') else True
"""
Variables that get allocated in heap need to get properly disposed.
"""

View File

@ -344,6 +344,9 @@ class VariableArray(Variable):
Getter for the array type
"""
def build_getter_declaration(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'name' : variable_name }
@ -362,6 +365,9 @@ class VariableArray(Variable):
Documentation for the getter
"""
def build_getter_documentation(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'public_array_element_format' : self.array_element.public_format,
'name' : variable_name }
@ -380,6 +386,9 @@ class VariableArray(Variable):
Builds the array getter implementation
"""
def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to, to_is_reference):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'from' : variable_name_from,
'to' : variable_name_to }
@ -405,6 +414,9 @@ class VariableArray(Variable):
Setter for the array type
"""
def build_setter_declaration(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'name' : variable_name }
@ -423,6 +435,9 @@ class VariableArray(Variable):
Documentation for the setter
"""
def build_setter_documentation(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'public_array_element_format' : self.array_element.public_format,
'name' : variable_name }
@ -441,6 +456,9 @@ class VariableArray(Variable):
Builds the array setter implementation
"""
def build_setter_implementation(self, line_prefix, variable_name_from, variable_name_to):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'from' : variable_name_from,
'to' : variable_name_to }

View File

@ -264,6 +264,9 @@ class VariableInteger(Variable):
Getter for the integer type
"""
def build_getter_declaration(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'public_format' : self.public_format,
'name' : variable_name }
@ -277,6 +280,9 @@ class VariableInteger(Variable):
Documentation for the getter
"""
def build_getter_documentation(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'public_format' : self.public_format,
'name' : variable_name }
@ -289,6 +295,9 @@ class VariableInteger(Variable):
Builds the Integer getter implementation
"""
def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to, to_is_reference):
if not self.visible:
return ""
needs_cast = True if self.public_format != self.private_format else False
translations = { 'lp' : line_prefix,
'from' : variable_name_from,
@ -311,6 +320,9 @@ class VariableInteger(Variable):
Setter for the integer type
"""
def build_setter_declaration(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'public_format' : self.public_format,
'name' : variable_name }
@ -324,6 +336,9 @@ class VariableInteger(Variable):
Documentation for the setter
"""
def build_setter_documentation(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'public_format' : self.public_format,
'name' : variable_name }
@ -337,6 +352,9 @@ class VariableInteger(Variable):
Implementation of the setter
"""
def build_setter_implementation(self, line_prefix, variable_name_from, variable_name_to):
if not self.visible:
return ""
needs_cast = True if self.public_format != self.private_format else False
translations = { 'lp' : line_prefix,
'from' : variable_name_from,

View File

@ -132,6 +132,9 @@ class VariableSequence(Variable):
of the variables in the sequence.
"""
def build_getter_declaration(self, line_prefix, variable_name):
if not self.visible:
return ""
built = ''
for member in self.members:
built += member['object'].build_getter_declaration(line_prefix, variable_name + '_' + member['name'])
@ -142,6 +145,9 @@ class VariableSequence(Variable):
Documentation for the getter
"""
def build_getter_documentation(self, line_prefix, variable_name):
if not self.visible:
return ""
built = ''
for member in self.members:
built += member['object'].build_getter_documentation(line_prefix, variable_name + '_' + member['name'])
@ -152,6 +158,9 @@ class VariableSequence(Variable):
Builds the Struct getter implementation
"""
def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to, to_is_reference):
if not self.visible:
return ""
built = ''
for member in self.members:
built += member['object'].build_getter_implementation(line_prefix,
@ -166,6 +175,9 @@ class VariableSequence(Variable):
of the variables in the sequence.
"""
def build_setter_declaration(self, line_prefix, variable_name):
if not self.visible:
return ""
built = ''
for member in self.members:
built += member['object'].build_setter_declaration(line_prefix, variable_name + '_' + member['name'])
@ -176,6 +188,9 @@ class VariableSequence(Variable):
Documentation for the setter
"""
def build_setter_documentation(self, line_prefix, variable_name):
if not self.visible:
return ""
built = ''
for member in self.members:
built += member['object'].build_setter_documentation(line_prefix, variable_name + '_' + member['name'])
@ -186,6 +201,9 @@ class VariableSequence(Variable):
Builds the Sequence setter implementation
"""
def build_setter_implementation(self, line_prefix, variable_name_from, variable_name_to):
if not self.visible:
return ""
built = ''
for member in self.members:
built += member['object'].build_setter_implementation(line_prefix,

View File

@ -193,6 +193,9 @@ class VariableString(Variable):
Getter for the string type
"""
def build_getter_declaration(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'name' : variable_name }
@ -205,6 +208,9 @@ class VariableString(Variable):
Documentation for the getter
"""
def build_getter_documentation(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'name' : variable_name }
@ -217,6 +223,9 @@ class VariableString(Variable):
Builds the String getter implementation
"""
def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to, to_is_reference):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'from' : variable_name_from,
'to' : variable_name_to }
@ -236,6 +245,9 @@ class VariableString(Variable):
Setter for the string type
"""
def build_setter_declaration(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'name' : variable_name }
@ -248,6 +260,9 @@ class VariableString(Variable):
Documentation for the setter
"""
def build_setter_documentation(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'name' : variable_name }
@ -269,6 +284,9 @@ class VariableString(Variable):
Builds the String setter implementation
"""
def build_setter_implementation(self, line_prefix, variable_name_from, variable_name_to):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'from' : variable_name_from,
'to' : variable_name_to }

View File

@ -163,6 +163,9 @@ class VariableStruct(Variable):
of the variables in the struct.
"""
def build_getter_declaration(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'format' : self.public_format,
'name' : variable_name }
@ -176,6 +179,9 @@ class VariableStruct(Variable):
Documentation for the getter
"""
def build_getter_documentation(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'format' : self.public_format,
'name' : variable_name }
@ -189,6 +195,9 @@ class VariableStruct(Variable):
Builds the Struct getter implementation
"""
def build_getter_implementation(self, line_prefix, variable_name_from, variable_name_to, to_is_reference):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'from' : variable_name_from,
'to' : variable_name_to }
@ -209,6 +218,9 @@ class VariableStruct(Variable):
of the variables in the struct.
"""
def build_setter_declaration(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'format' : self.public_format,
'name' : variable_name }
@ -222,6 +234,9 @@ class VariableStruct(Variable):
Documentation for the setter
"""
def build_setter_documentation(self, line_prefix, variable_name):
if not self.visible:
return ""
translations = { 'lp' : line_prefix,
'format' : self.public_format,
'name' : variable_name }
@ -234,6 +249,9 @@ class VariableStruct(Variable):
Builds the Struct setter implementation
"""
def build_setter_implementation(self, line_prefix, variable_name_from, variable_name_to):
if not self.visible:
return ""
built = ''
for member in self.members:
built += member['object'].build_setter_implementation(line_prefix,