diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2011-06-22 13:26:15 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2012-03-20 15:31:30 +0100 |
commit | 12a5ce3dc5d9b130de1eba7038c9915428fac802 (patch) | |
tree | f87dcca64e8ade04d040e9904199e5062fc21c3b /python_modules/marshal.py | |
parent | 0067c31bad1fadbfceba7014497374b9daf9a6a0 (diff) | |
download | spice-protocol-12a5ce3dc5d9b130de1eba7038c9915428fac802.tar.gz spice-protocol-12a5ce3dc5d9b130de1eba7038c9915428fac802.tar.xz spice-protocol-12a5ce3dc5d9b130de1eba7038c9915428fac802.zip |
handle @ifdef on messages and channels
Diffstat (limited to 'python_modules/marshal.py')
-rw-r--r-- | python_modules/marshal.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/python_modules/marshal.py b/python_modules/marshal.py index 5b4dfdd..d93f983 100644 --- a/python_modules/marshal.py +++ b/python_modules/marshal.py @@ -333,6 +333,8 @@ 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.out_prefix = "" function_name = "spice_marshall_" + message.c_name() if writer.is_generated("marshaller", function_name): @@ -364,6 +366,8 @@ 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.newline() return function_name @@ -371,16 +375,30 @@ def write_protocol_marshaller(writer, proto, is_server, private_marshallers): functions = {} for c in proto.channels: channel = c.channel_type + if channel.has_attr("ifdef"): + writer.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) - functions[f] = True + if channel.has_attr("ifdef") and not functions.has_key(f): + functions[f] = channel.attributes["ifdef"][0] + elif message.has_attr("ifdef") and not functions.has_key(f): + functions[f] = message.attributes["ifdef"][0] + else: + functions[f] = True else: for m in channel.server_messages: message = m.message_type - f= write_message_marshaller(writer, message, is_server, private_marshallers) - functions[f] = True + f = write_message_marshaller(writer, message, is_server, private_marshallers) + if channel.has_attr("ifdef") and not functions.has_key(f): + functions[f] = channel.attributes["ifdef"][0] + elif message.has_attr("ifdef") and not functions.has_key(f): + functions[f] = message.attributes["ifdef"][0] + else: + functions[f] = True + if channel.has_attr("ifdef"): + writer.endif(channel.attributes["ifdef"][0]) if private_marshallers: scope = writer.function("spice_message_marshallers_get" + writer.public_prefix, @@ -391,7 +409,11 @@ def write_protocol_marshaller(writer, proto, is_server, private_marshallers): member = f[len("spice_marshall_"):] if not member.startswith("msg"): member = "msg_" + member + if functions[f] != True: + writer.ifdef(functions[f]) writer.assign("marshallers.%s" % member, f) + if functions[f] != True: + writer.endif(functions[f]) writer.newline() writer.statement("return &marshallers") |