[PATCH] Fix handling of whitespae in preprocessor macros for API generator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
---
 docs/apibuild.py               |  8 ++++++++
 include/libvirt/libvirt-host.h | 12 ++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 7549a63..9fa9361 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -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] == "'":
diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h
index 5bd9563..53b529f 100644
--- a/include/libvirt/libvirt-host.h
+++ b/include/libvirt/libvirt-host.h
@@ -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,
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]