[Spice-devel] [PATCH 1/4] codegen: typedef the protocol enums
Marc-André Lureau
marcandre.lureau at gmail.com
Wed Jun 22 02:51:34 PDT 2011
Commit 9d5ef9beeca722b2ceff7d15aaa3aaaaf07ecfbf in spice-protocol
introduced a typedef manually in the generated enums.h header.
This patch adds them automatically to all enums during enums.h generation.
---
python_modules/ptypes.py | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 9c4b7de..9e444f5 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -280,7 +280,7 @@ class EnumType(EnumBaseType):
return "enum %s" % self.name
def c_define(self, writer):
- writer.write("enum ")
+ writer.write("typedef enum ")
writer.write(self.c_name())
writer.begin_block()
values = self.names.keys()
@@ -296,7 +296,11 @@ class EnumType(EnumBaseType):
writer.newline()
writer.write(codegen.prefix_underscore_upper(self.name.upper(), "ENUM_END"))
writer.newline()
- writer.end_block(semicolon=True)
+ writer.end_block(newline=False)
+ writer.write(" ")
+ writer.write(self.c_name())
+ writer.write(";")
+ writer.newline()
writer.newline()
class FlagsType(EnumBaseType):
@@ -330,7 +334,7 @@ class FlagsType(EnumBaseType):
return "flags %s" % self.name
def c_define(self, writer):
- writer.write("enum ")
+ writer.write("typedef enum ")
writer.write(self.c_name())
writer.begin_block()
values = self.names.keys()
@@ -347,7 +351,11 @@ class FlagsType(EnumBaseType):
writer.write(codegen.prefix_underscore_upper(self.name.upper(), "MASK"))
writer.write(" = 0x%x" % (mask))
writer.newline()
- writer.end_block(semicolon=True)
+ writer.end_block(newline=False)
+ writer.write(" ")
+ writer.write(self.c_name())
+ writer.write(";")
+ writer.newline()
writer.newline()
class ArrayType(Type):
--
1.7.5.2
More information about the Spice-devel
mailing list