[Spice-devel] [PATCH v4 04/41] dissector: Decorate writer class to make easier ifdef/endif handling

Christophe Fergeau cfergeau at redhat.com
Thu Jul 30 08:13:43 PDT 2015


On Thu, Jul 23, 2015 at 04:54:21PM +0100, Frediano Ziglio wrote:
> I'm generating code for dissector from demarshaller.
> Make simple to hangle ifdef/endif not having to check manually attribute.

'to handle'
This really should be more descriptive, my understanding is that this
dynamically generates methods to handle ifdef/ifdef_else/endif and avoid
code duplication? And existing code could be patched with:

diff --git a/python_modules/marshal.py b/python_modules/marshal.py
index 1d38d3d..c2ed854 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -334,8 +334,7 @@ def write_container_marshaller(writer, container, src):
             write_member_marshaller(writer, container, m, src, scope)

 def write_message_marshaller(writer, message, is_server, private):
-    if message.has_attr("ifdef"):
-        writer.ifdef(message.attributes["ifdef"][0])
+    writer.ifdef(message)
     writer.out_prefix = ""
     function_name = "spice_marshall_" + message.c_name()
     if writer.is_generated("marshaller", function_name):
@@ -367,8 +366,7 @@ def write_message_marshaller(writer, message, is_server, private):
         write_container_marshaller(writer, message, src)

     writer.end_block()
-    if message.has_attr("ifdef"):
-        writer.endif(message.attributes["ifdef"][0])
+    writer.endif(message)
     writer.newline()
     return function_name
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150730/4930a7e2/attachment.sig>


More information about the Spice-devel mailing list