[libvirt PATCH 4/4] scripts: emit raw enum value in API build description

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

 



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...

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 scripts/apibuild.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/scripts/apibuild.py b/scripts/apibuild.py
index 9faf15a75e..d63489ba62 100755
--- a/scripts/apibuild.py
+++ b/scripts/apibuild.py
@@ -1027,11 +1027,14 @@ class CParser:
                     return token
 
                 strValue = None
+                rawValue = None
                 if len(lst) == 1 and lst[0][0] == '"' and lst[0][-1] == '"':
                     strValue = lst[0][1:-1]
+                else:
+                    rawValue = " ".join(lst)
                 (args, desc) = self.parseMacroComment(name, 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
 
         #
@@ -2178,13 +2181,16 @@ class docBuilder:
             desc = None
             params = None
             strValue = None
+            rawValue = None
         else:
-            (args, desc, params, strValue) = id.info
+            (args, desc, params, strValue, rawValue) = id.info
 
         if params is not None:
             output.write(" params='%s'" % params)
         if strValue is not None:
             output.write(" string='%s'" % strValue)
+        else:
+            output.write(" raw='%s'" % rawValue)
         output.write(">\n")
 
         if desc is not None and desc != "":
-- 
2.26.2




[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]

  Powered by Linux