]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix handling of whitespae in preprocessor macros for API generator
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 4 Dec 2014 12:06:32 +0000 (12:06 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 4 Dec 2014 15:00:30 +0000 (15:00 +0000)
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
include/libvirt/libvirt-host.h

index 7549a63449de6caaf612f64868a7665d09bca972..9fa9361cc202cd79072fb260e904b55f45fc58e1 100755 (executable)
@@ -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] == "'":
index 5bd95639f7fe6a2688eb108edef5d743757dd38b..53b529f2144ac07d860c59ca0098a391b69848c4 100644 (file)
@@ -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,