Param parser and XML output: Add support for volatile attribute

This allows to mark parameters as volatile.
This commit is contained in:
Lorenz Meier 2018-01-07 17:41:11 +01:00
parent 27e64149f0
commit ac5f856d2d
2 changed files with 16 additions and 0 deletions

View File

@ -57,6 +57,7 @@ class Parameter(object):
self.name = name
self.type = type
self.default = default
self.volatile = "false"
def GetName(self):
return self.name
@ -67,6 +68,9 @@ class Parameter(object):
def GetDefault(self):
return self.default
def GetVolatile(self):
return self.volatile
def SetField(self, code, value):
"""
Set named field value
@ -85,6 +89,12 @@ class Parameter(object):
"""
self.bitmask[index] = bit
def SetVolatile(self):
"""
Set volatile flag
"""
self.volatile = "true"
def GetFieldCodes(self):
"""
Return list of existing field codes in convenient order
@ -282,6 +292,8 @@ class SourceParser(object):
for tag in tags:
if tag == "group":
group = tags[tag]
elif tag == "volatile":
param.SetVolatile()
elif tag not in self.valid_tags:
sys.stderr.write("Skipping invalid documentation tag: '%s'\n" % tag)
return False
@ -332,6 +344,9 @@ class SourceParser(object):
if default != "" and not self.IsNumber(default):
sys.stderr.write("Default value not number: {0} {1}\n".format(name, default))
return False
# if default != "" and "." not in default:
# sys.stderr.write("Default value does not contain dot (e.g. 10 needs to be written as 10.0): {0} {1}\n".format(name, default))
# return False
if min != "":
if not self.IsNumber(min):
sys.stderr.write("Min value not number: {0} {1}\n".format(name, min))

View File

@ -41,6 +41,7 @@ class XMLOutput():
xml_param.attrib["name"] = param.GetName()
xml_param.attrib["default"] = param.GetDefault()
xml_param.attrib["type"] = param.GetType()
xml_param.attrib["volatile"] = param.GetVolatile()
last_param_name = param.GetName()
for code in param.GetFieldCodes():
value = param.GetFieldValue(code)