diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2011-06-22 13:22:22 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2012-03-20 15:31:30 +0100 |
commit | d8975877c6e275961ee7d891c8dd2fc67d30305e (patch) | |
tree | 07682f30f91ac418f9c4c5b7cb491a1a52020cf3 | |
parent | 7f23ab54aae7dc820380d54ad99decc176e93ff1 (diff) | |
download | spice-protocol-d8975877c6e275961ee7d891c8dd2fc67d30305e.tar.gz spice-protocol-d8975877c6e275961ee7d891c8dd2fc67d30305e.tar.xz spice-protocol-d8975877c6e275961ee7d891c8dd2fc67d30305e.zip |
add ifdef/endif methods to spice code generator
These methods will be needed to be able to make some fields optional
in spice.proto
-rw-r--r-- | python_modules/codegen.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/python_modules/codegen.py b/python_modules/codegen.py index 116760c..6d53551 100644 --- a/python_modules/codegen.py +++ b/python_modules/codegen.py @@ -322,6 +322,18 @@ class CodeWriter: def macro(self, name, args, define): self.write("#define %s(%s) %s" % (name, args, define)).newline() + def ifdef(self, name): + indentation = self.indentation + self.indentation = 0; + self.write("#ifdef %s" % (name)).newline() + self.indentation = indentation + + def endif(self, name): + indentation = self.indentation + self.indentation = 0; + self.write("#endif /* %s */" % (name)).newline() + self.indentation = indentation + def add_function_variable(self, ctype, name): if self.function_variables.has_key(name): assert(self.function_variables[name] == ctype) |