mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
scripts: emit raw enum value in API build description
Currently the value for an enum is only emitted if it is a plain string. If the enum is an integer or hex value, or a complex code block, it is omitted from the API build. This fixes that by emitting the raw value if no string value is present. With this change: <macro name='LIBVIR_CHECK_VERSION' file='libvirt-common' params='major,minor,micro'> <macro name='LIBVIR_VERSION_NUMBER' file='libvirt-common'> <macro name='VIR_COPY_CPUMAP' file='libvirt-domain' params='cpumaps,maplen,vcpu,cpumap'> ...snip... <macro name='LIBVIR_CHECK_VERSION' file='libvirt-common' params='major,minor,micro' raw='((major) * 1000000 + (minor) * 1000 + (micro) <= LIBVIR_VERSION_NUMBER)'> <macro name='LIBVIR_VERSION_NUMBER' file='libvirt-common' raw='6004000'> <macro name='VIR_COPY_CPUMAP' file='libvirt-domain' params='cpumaps,maplen,vcpu,cpumap' raw='memcpy(cpumap, VIR_GET_CPUMAP(cpumaps, maplen, vcpu), maplen)'> ...snip... Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
38f3fa6140
commit
61fdc96706
@ -500,8 +500,8 @@ class CLexer:
|
|||||||
|
|
||||||
endArg = self.tokens[1][1].find(")")
|
endArg = self.tokens[1][1].find(")")
|
||||||
if endArg != -1:
|
if endArg != -1:
|
||||||
extra = self.tokens[1][1][endArg+1:]
|
extra = self.tokens[1][1][endArg + 1:]
|
||||||
name = self.tokens[1][1][0:endArg+1]
|
name = self.tokens[1][1][0:endArg + 1]
|
||||||
newtokens.append(('preproc', name))
|
newtokens.append(('preproc', name))
|
||||||
if extra != "":
|
if extra != "":
|
||||||
newtokens.append(('preproc', extra))
|
newtokens.append(('preproc', extra))
|
||||||
@ -1017,7 +1017,7 @@ class CParser:
|
|||||||
paramStart = name.find("(")
|
paramStart = name.find("(")
|
||||||
params = None
|
params = None
|
||||||
if paramStart != -1:
|
if paramStart != -1:
|
||||||
params = name[paramStart+1:-1]
|
params = name[paramStart + 1:-1]
|
||||||
name = name[0:paramStart]
|
name = name[0:paramStart]
|
||||||
|
|
||||||
# skip hidden macros
|
# skip hidden macros
|
||||||
@ -1027,11 +1027,14 @@ class CParser:
|
|||||||
return token
|
return token
|
||||||
|
|
||||||
strValue = None
|
strValue = None
|
||||||
|
rawValue = None
|
||||||
if len(lst) == 1 and lst[0][0] == '"' and lst[0][-1] == '"':
|
if len(lst) == 1 and lst[0][0] == '"' and lst[0][-1] == '"':
|
||||||
strValue = lst[0][1:-1]
|
strValue = lst[0][1:-1]
|
||||||
|
else:
|
||||||
|
rawValue = " ".join(lst)
|
||||||
(args, desc) = self.parseMacroComment(name, not self.is_header)
|
(args, desc) = self.parseMacroComment(name, not self.is_header)
|
||||||
self.index_add(name, self.filename, not self.is_header,
|
self.index_add(name, self.filename, not self.is_header,
|
||||||
"macro", (args, desc, params, strValue))
|
"macro", (args, desc, params, strValue, rawValue))
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -2178,13 +2181,16 @@ class docBuilder:
|
|||||||
desc = None
|
desc = None
|
||||||
params = None
|
params = None
|
||||||
strValue = None
|
strValue = None
|
||||||
|
rawValue = None
|
||||||
else:
|
else:
|
||||||
(args, desc, params, strValue) = id.info
|
(args, desc, params, strValue, rawValue) = id.info
|
||||||
|
|
||||||
if params is not None:
|
if params is not None:
|
||||||
output.write(" params='%s'" % params)
|
output.write(" params='%s'" % params)
|
||||||
if strValue is not None:
|
if strValue is not None:
|
||||||
output.write(" string='%s'" % strValue)
|
output.write(" string='%s'" % strValue)
|
||||||
|
else:
|
||||||
|
output.write(" raw='%s'" % escape(rawValue))
|
||||||
output.write(">\n")
|
output.write(">\n")
|
||||||
|
|
||||||
if desc is not None and desc != "":
|
if desc is not None and desc != "":
|
||||||
|
Loading…
Reference in New Issue
Block a user