summaryrefslogtreecommitdiffstats
path: root/python_modules/codegen.py
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-09-30 11:19:38 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2012-03-20 15:31:30 +0100
commitca57afda341a1187a9c367e5be71744979dd7a86 (patch)
tree641b51116b084d2db1734b3a9d5a44af0a2dd26a /python_modules/codegen.py
parent12a5ce3dc5d9b130de1eba7038c9915428fac802 (diff)
downloadspice-protocol-ca57afda341a1187a9c367e5be71744979dd7a86.tar.gz
spice-protocol-ca57afda341a1187a9c367e5be71744979dd7a86.tar.xz
spice-protocol-ca57afda341a1187a9c367e5be71744979dd7a86.zip
spice_codegen: Always write a channels entry for an ifdef-ed channel
Before this patch, if a channel is defined conditionally in spice.proto (because it depends on external headers like the smartcard channel), spice_codegen would write an entry to the channels array in spice_get_*_channel_parser which would only take up a place in the array if the ifdef condition is true, thus moving up all other intializers one place when it is not true. This was causing issues (crashes) when building spice-gtk with the combination of usbredir support enabled and smartcard support disabled. This patch fixes this by adding #else { NULL, 0 }, to the generated code. Thanks to coolper chen <lixin.chen@saicocch.com> for reporting this! Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'python_modules/codegen.py')
-rw-r--r--python_modules/codegen.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/python_modules/codegen.py b/python_modules/codegen.py
index 6d53551..009cf95 100644
--- a/python_modules/codegen.py
+++ b/python_modules/codegen.py
@@ -328,6 +328,12 @@ class CodeWriter:
self.write("#ifdef %s" % (name)).newline()
self.indentation = indentation
+ def ifdef_else(self, name):
+ indentation = self.indentation
+ self.indentation = 0;
+ self.write("#else /* %s */" % (name)).newline()
+ self.indentation = indentation
+
def endif(self, name):
indentation = self.indentation
self.indentation = 0;