summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2015-07-21 17:45:32 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2015-07-23 11:11:03 +0200
commitaa43c0d61e0b5d309fca5fb2016c9d0a7fb871b1 (patch)
tree1e88d7aeb65492edd7ec756e27312d135e2ef020
parent86b0568055443b7d729fb629f07e94409013401e (diff)
codegen: Simplify if/else blocks
Blocks were mainly the same, this reduces the amount of code. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--python_modules/marshal.py29
1 files changed, 11 insertions, 18 deletions
diff --git a/python_modules/marshal.py b/python_modules/marshal.py
index b77b910..1d38d3d 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -380,25 +380,18 @@ def write_protocol_marshaller(writer, proto, is_server, private_marshallers):
writer.ifdef(channel.attributes["ifdef"][0])
writer.header.ifdef(channel.attributes["ifdef"][0])
if is_server:
- for m in channel.client_messages:
- message = m.message_type
- f = write_message_marshaller(writer, message, is_server, private_marshallers)
- if channel.has_attr("ifdef") and f not in functions:
- functions[f] = channel.attributes["ifdef"][0]
- elif message.has_attr("ifdef") and f not in functions:
- functions[f] = message.attributes["ifdef"][0]
- else:
- functions[f] = True
+ messages = channel.client_messages
else:
- for m in channel.server_messages:
- message = m.message_type
- f = write_message_marshaller(writer, message, is_server, private_marshallers)
- if channel.has_attr("ifdef") and f not in functions:
- functions[f] = channel.attributes["ifdef"][0]
- elif message.has_attr("ifdef") and f not in functions:
- functions[f] = message.attributes["ifdef"][0]
- else:
- functions[f] = True
+ messages = channel.server_messages
+ for m in messages:
+ message = m.message_type
+ f = write_message_marshaller(writer, message, is_server, private_marshallers)
+ if channel.has_attr("ifdef") and f not in functions:
+ functions[f] = channel.attributes["ifdef"][0]
+ elif message.has_attr("ifdef") and f not in functions:
+ functions[f] = message.attributes["ifdef"][0]
+ else:
+ functions[f] = True
if channel.has_attr("ifdef"):
writer.endif(channel.attributes["ifdef"][0])
writer.header.endif(channel.attributes["ifdef"][0])