mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
scripts: fix tokenizing of enum parameters in API builder
The API build script tokenizes enums declarations by first splitting on whitespace. This is unhelpful as it means an enum # define VIR_USE_CPU(cpumap, cpu) ((cpumap)[(cpu) / 8] |= (1 << ((cpu) % 8))) Gets tokenized as #define VIR_USE_CPU(cpumap, cpu) ((cpumap)[(cpu) / 8] |= (1 << ((cpu) % 8))) With this change, the set of parameters are all merged into the first token: #define VIR_USE_CPU(cpumap,cpu) ((cpumap)[(cpu) / 8] |= (1 << ((cpu) % 8))) which is more convenient to process later on in the script. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
50eb22e343
commit
34204f9923
@ -494,6 +494,28 @@ class CLexer:
|
|||||||
if self.tokens[0][1] == "#":
|
if self.tokens[0][1] == "#":
|
||||||
self.tokens[0] = ('preproc', "#" + self.tokens[1][1])
|
self.tokens[0] = ('preproc', "#" + self.tokens[1][1])
|
||||||
del self.tokens[1]
|
del self.tokens[1]
|
||||||
|
|
||||||
|
if self.tokens[0][1] == "#define" and "(" in self.tokens[1][1]:
|
||||||
|
newtokens = [self.tokens[0]]
|
||||||
|
|
||||||
|
endArg = self.tokens[1][1].find(")")
|
||||||
|
if endArg != -1:
|
||||||
|
extra = self.tokens[1][1][endArg+1:]
|
||||||
|
name = self.tokens[1][1][0:endArg+1]
|
||||||
|
newtokens.append(('preproc', name))
|
||||||
|
if extra != "":
|
||||||
|
newtokens.append(('preproc', extra))
|
||||||
|
else:
|
||||||
|
name = self.tokens[1][1]
|
||||||
|
for token in self.tokens[2:]:
|
||||||
|
if name is not None:
|
||||||
|
name = name + token[1]
|
||||||
|
if ")" in token[1]:
|
||||||
|
newtokens.append(('preproc', name))
|
||||||
|
name = None
|
||||||
|
else:
|
||||||
|
newtokens.append(token)
|
||||||
|
self.tokens = newtokens
|
||||||
break
|
break
|
||||||
nline = len(line)
|
nline = len(line)
|
||||||
if line[0] == '"' or line[0] == "'":
|
if line[0] == '"' or line[0] == "'":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user