提交 64702ac3 编写于 作者: D Daniel P. Berrange

Fix handling of whitespae in preprocessor macros for API generator

The apibuild.py script did not handle whitespace in preprocessor
macros, so it failed to detect constants declared with '# define'
instead of '#define'. Since we now correctly indent our public
header files, we have silently lost all constants from
libvirt-api.xml. This also caused us to not detect formatting
errors in constant docs
上级 3ecebf07
......@@ -459,6 +459,14 @@ class CLexer:
if line[0] == '#':
self.tokens = map((lambda x: ('preproc', x)),
string.split(line))
# We might have whitespace between the '#' and preproc
# macro name, so instead of having a single token element
# of '#define' we might end up with '#' and 'define'. This
# merges them back together
if self.tokens[0][1] == "#":
self.tokens[0] = ('preproc', self.tokens[0][1] + self.tokens[1][1])
self.tokens = self.tokens[:1] + self.tokens[2:]
break
l = len(line)
if line[0] == '"' or line[0] == "'":
......
......@@ -536,28 +536,32 @@ struct _virNodeMemoryStats {
*/
# define VIR_NODE_MEMORY_SHARED_PAGES_SHARING "shm_pages_sharing"
/* VIR_NODE_MEMORY_SHARED_PAGES_UNSHARED:
/*
* VIR_NODE_MEMORY_SHARED_PAGES_UNSHARED:
*
* Macro for typed parameter that represents how many pages unique
* but repeatedly checked for merging.
*/
# define VIR_NODE_MEMORY_SHARED_PAGES_UNSHARED "shm_pages_unshared"
/* VIR_NODE_MEMORY_SHARED_PAGES_VOLATILE:
/*
* VIR_NODE_MEMORY_SHARED_PAGES_VOLATILE:
*
* Macro for typed parameter that represents how many pages changing
* too fast to be placed in a tree.
*/
# define VIR_NODE_MEMORY_SHARED_PAGES_VOLATILE "shm_pages_volatile"
/* VIR_NODE_MEMORY_SHARED_FULL_SCAN:
/*
* VIR_NODE_MEMORY_SHARED_FULL_SCANS:
*
* Macro for typed parameter that represents how many times all
* mergeable areas have been scanned.
*/
# define VIR_NODE_MEMORY_SHARED_FULL_SCANS "shm_full_scans"
/* VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES:
/*
* VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES:
*
* Macro for typed parameter that represents whether pages from
* different NUMA nodes can be merged. The parameter has type int,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册