[Spice-devel] [PATCH v6 01/42] Supports ifdef attribute on enumerations

Frediano Ziglio fziglio at redhat.com
Thu Aug 13 06:11:40 PDT 2015


This allows to exclude some enumaration for different
purposes.
For instance one could use some enumerations only on
marshaller to avoid clash with some other demarshaller
defines.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 python_modules/ptypes.py | 2 --
 spice_codegen.py         | 6 ++++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 7ab2771..c1eb756 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -390,7 +390,6 @@ class EnumType(EnumBaseType):
         writer.write(self.c_name())
         writer.write(";")
         writer.newline()
-        writer.newline()
 
 class FlagsType(EnumBaseType):
     def __init__(self, bits, name, flags, attribute_list):
@@ -444,7 +443,6 @@ class FlagsType(EnumBaseType):
         writer.write(self.c_name())
         writer.write(";")
         writer.newline()
-        writer.newline()
 
 class ArrayType(Type):
     def __init__(self, element_type, size):
diff --git a/spice_codegen.py b/spice_codegen.py
index 569cccc..2f3dbff 100755
--- a/spice_codegen.py
+++ b/spice_codegen.py
@@ -85,9 +85,15 @@ def write_enums(writer, describe=False):
     # Define enums
     for t in ptypes.get_named_types():
         if isinstance(t, ptypes.EnumBaseType):
+            if t.has_attr("ifdef"):
+                writer.ifdef(t.attributes["ifdef"][0])
             t.c_define(writer)
             if describe:
+                writer.newline()
                 t.c_describe(writer)
+            if t.has_attr("ifdef"):
+                writer.endif(t.attributes["ifdef"][0])
+            writer.newline()
 
     write_channel_type_enum(writer)
     if (describe):
-- 
2.4.3



More information about the Spice-devel mailing list