scripts: emit enum parameters in API build description

Currently the information about enums in the API document lacks any
mention of parameters, so it is impossible to tell what kind of enum
declaration is present in the libvirt API header. With this change

  <macro name='LIBVIR_CHECK_VERSION' file='libvirt-common'>
  <macro name='VIR_COPY_CPUMAP' file='libvirt-domain'>
  ...snip...

becomes

  <macro name='LIBVIR_CHECK_VERSION' file='libvirt-common' params='major,minor,micro'>
  <macro name='VIR_COPY_CPUMAP' file='libvirt-domain' params='cpumaps,maplen,vcpu,cpumap'>
  ...snip...

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2020-05-19 12:30:57 +01:00
parent 34204f9923
commit 38f3fa6140

View File

@ -1013,10 +1013,12 @@ class CParser:
token[1][0] != '#'):
lst.append(token[1])
token = self.lexer.token()
try:
name = name.split('(')[0]
except Exception:
pass
paramStart = name.find("(")
params = None
if paramStart != -1:
params = name[paramStart+1:-1]
name = name[0:paramStart]
# skip hidden macros
if name in hidden_macros:
@ -1029,7 +1031,7 @@ class CParser:
strValue = lst[0][1:-1]
(args, desc) = self.parseMacroComment(name, not self.is_header)
self.index_add(name, self.filename, not self.is_header,
"macro", (args, desc, strValue))
"macro", (args, desc, params, strValue))
return token
#
@ -2174,10 +2176,13 @@ class docBuilder:
if id.info is None:
args = []
desc = None
params = None
strValue = None
else:
(args, desc, strValue) = id.info
(args, desc, params, strValue) = id.info
if params is not None:
output.write(" params='%s'" % params)
if strValue is not None:
output.write(" string='%s'" % strValue)
output.write(">\n")