summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2016-06-23 12:57:21 +0200
committerFrediano Ziglio <fziglio@redhat.com>2016-06-24 10:02:58 +0100
commit073d064b86d5233d3cbe2136ddfb2a8313b6130e (patch)
tree17990b40abd6468af4b8cb41611278b62ed3c93c
parent0eb567e6fb41ce4bf6d6b6bfdd113091cb2c72f0 (diff)
codegen: Autogenerate client_marshallers.h
This commit adds autogeneration of a generated_client_marshallers.h header, which is then included in client_marshallers.h This allows to remove the SpiceMessageMarshallers struct from this file, which has to match what the generated code expects. Acked-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--common/Makefile.am6
-rw-r--r--common/client_marshallers.h46
-rw-r--r--python_modules/marshal.py28
3 files changed, 33 insertions, 47 deletions
diff --git a/common/Makefile.am b/common/Makefile.am
index 2dd56f3..4b8f63a 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -5,6 +5,7 @@ CLIENT_MARSHALLERS = \
generated_client_demarshallers.c \
generated_client_demarshallers1.c \
generated_client_marshallers.c \
+ generated_client_marshallers.h \
generated_client_marshallers1.c \
$(NULL)
@@ -107,8 +108,11 @@ generated_client_demarshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS)
generated_client_demarshallers1.c: $(top_srcdir)/spice1.proto $(MARSHALLERS_DEPS)
$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --client --include common/messages.h --prefix 1 --ptrsize 8 $< $@ >/dev/null
+generated_client_marshallers.h: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS)
+ $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --client --include common/messages.h -H $< $@ >/dev/null
+
generated_client_marshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS)
- $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include common/messages.h --include client_marshallers.h --client $< $@ >/dev/null
+ $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include client_marshallers.h --client $< $@ >/dev/null
generated_client_marshallers1.c: $(top_srcdir)/spice1.proto $(MARSHALLERS_DEPS)
$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include common/messages.h --include client_marshallers.h --client --prefix 1 --ptrsize 8 $< $@ >/dev/null
diff --git a/common/client_marshallers.h b/common/client_marshallers.h
index 2074323..d3e26b4 100644
--- a/common/client_marshallers.h
+++ b/common/client_marshallers.h
@@ -25,56 +25,12 @@
#include <spice/protocol.h>
+#include "generated_client_marshallers.h"
#include "marshaller.h"
#include "messages.h"
SPICE_BEGIN_DECLS
-typedef struct {
- void (*msg_SpiceMsgEmpty)(SpiceMarshaller *m, SpiceMsgEmpty *msg);
- void (*msg_SpiceMsgData)(SpiceMarshaller *m, SpiceMsgData *msg);
- void (*msg_SpiceMsgCompressedData)(SpiceMarshaller *m, SpiceMsgCompressedData *msg);
- void (*msgc_ack_sync)(SpiceMarshaller *m, SpiceMsgcAckSync *msg);
- void (*msgc_pong)(SpiceMarshaller *m, SpiceMsgPing *msg);
- void (*msgc_disconnecting)(SpiceMarshaller *m, SpiceMsgDisconnect *msg);
- void (*msgc_main_client_info)(SpiceMarshaller *m, SpiceMsgcClientInfo *msg);
- void (*msgc_main_mouse_mode_request)(SpiceMarshaller *m, SpiceMsgcMainMouseModeRequest *msg);
- void (*msgc_main_agent_start)(SpiceMarshaller *m, SpiceMsgcMainAgentStart *msg);
- void (*msgc_main_agent_token)(SpiceMarshaller *m, SpiceMsgcMainAgentTokens *msg);
- void (*msgc_main_migrate_dst_do_seamless)(SpiceMarshaller *m, SpiceMsgcMainMigrateDstDoSeamless *msg);
- void (*msgc_display_init)(SpiceMarshaller *m, SpiceMsgcDisplayInit *msg);
- void (*msgc_display_stream_report)(SpiceMarshaller *m, SpiceMsgcDisplayStreamReport *msg);
- void (*msgc_display_gl_draw_done)(SpiceMarshaller *m, SpiceMsgcDisplayGlDrawDone *msg);
- void (*msgc_inputs_key_down)(SpiceMarshaller *m, SpiceMsgcKeyDown *msg);
- void (*msgc_inputs_key_up)(SpiceMarshaller *m, SpiceMsgcKeyUp *msg);
- void (*msgc_inputs_key_modifiers)(SpiceMarshaller *m, SpiceMsgcKeyModifiers *msg);
- void (*msgc_inputs_mouse_motion)(SpiceMarshaller *m, SpiceMsgcMouseMotion *msg);
- void (*msgc_inputs_mouse_position)(SpiceMarshaller *m, SpiceMsgcMousePosition *msg);
- void (*msgc_inputs_mouse_press)(SpiceMarshaller *m, SpiceMsgcMousePress *msg);
- void (*msgc_inputs_mouse_release)(SpiceMarshaller *m, SpiceMsgcMouseRelease *msg);
- void (*msgc_record_data)(SpiceMarshaller *m, SpiceMsgcRecordPacket *msg);
- void (*msgc_record_mode)(SpiceMarshaller *m, SpiceMsgcRecordMode *msg);
- void (*msgc_record_start_mark)(SpiceMarshaller *m, SpiceMsgcRecordStartMark *msg);
- void (*msgc_tunnel_service_add)(SpiceMarshaller *m, SpiceMsgcTunnelAddGenericService *msg, SpiceMarshaller **name_out, SpiceMarshaller **description_out);
- void (*msgc_tunnel_service_remove)(SpiceMarshaller *m, SpiceMsgcTunnelRemoveService *msg);
- void (*msgc_tunnel_socket_open_ack)(SpiceMarshaller *m, SpiceMsgcTunnelSocketOpenAck *msg);
- void (*msgc_tunnel_socket_open_nack)(SpiceMarshaller *m, SpiceMsgcTunnelSocketOpenNack *msg);
- void (*msgc_tunnel_socket_fin)(SpiceMarshaller *m, SpiceMsgcTunnelSocketFin *msg);
- void (*msgc_tunnel_socket_closed)(SpiceMarshaller *m, SpiceMsgcTunnelSocketClosed *msg);
- void (*msgc_tunnel_socket_closed_ack)(SpiceMarshaller *m, SpiceMsgcTunnelSocketClosedAck *msg);
- void (*msgc_tunnel_socket_data)(SpiceMarshaller *m, SpiceMsgcTunnelSocketData *msg);
- void (*msgc_tunnel_socket_token)(SpiceMarshaller *m, SpiceMsgcTunnelSocketTokens *msg);
-#ifdef USE_SMARTCARD
- void (*msgc_smartcard_atr)(SpiceMarshaller *m, VSCMsgATR *msg);
- void (*msgc_smartcard_error)(SpiceMarshaller *m, VSCMsgError *msg);
- void (*msgc_smartcard_header)(SpiceMarshaller *m, VSCMsgHeader *msg);
- void (*msgc_smartcard_data)(SpiceMarshaller *m, SpiceMsgcSmartcard *msg, SpiceMarshaller **reader_name_out);
- void (*msgc_smartcard_reader_add)(SpiceMarshaller *m, VSCMsgReaderAdd *msg);
-#endif
- void (*msgc_port_event)(SpiceMarshaller *m, SpiceMsgcPortEvent *msg);
- void (*msgc_display_preferred_compression)(SpiceMarshaller *m, SpiceMsgcDisplayPreferredCompression *msg);
-} SpiceMessageMarshallers;
-
SpiceMessageMarshallers *spice_message_marshallers_get(void);
SpiceMessageMarshallers *spice_message_marshallers_get1(void);
diff --git a/python_modules/marshal.py b/python_modules/marshal.py
index dc36e18..0483d3a 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -17,6 +17,9 @@ def write_includes(writer):
src = "_H_"+src[:-2]
writer.header.writeln("#ifndef %s" % src)
writer.header.writeln("#define %s" % src)
+ writer.header.newline()
+ writer.header.writeln("SPICE_BEGIN_DECLS")
+ writer.header.newline()
writer.writeln("#include <string.h>")
writer.writeln("#include <assert.h>")
@@ -345,6 +348,7 @@ def write_container_marshaller(writer, container, src):
def write_message_marshaller(writer, message, private):
if message.has_attr("ifdef"):
writer.ifdef(message.attributes["ifdef"][0])
+ writer.header.ifdef(message.attributes["ifdef"][0])
writer.out_prefix = ""
function_name = "spice_marshall_" + message.c_name()
if writer.is_generated("marshaller", function_name):
@@ -357,7 +361,15 @@ def write_message_marshaller(writer, message, private):
n = [", SpiceMarshaller **%s_out" % name for name in names]
names_args = "".join(n)
- if not private:
+ if private:
+ message_name = message.c_name()
+ if (not message_name.startswith("msgc_")):
+ #small bug above, checks for startswith("msg") which
+ #matches "msgc" and appends "msg_" if this fails causing
+ #inconsistencies
+ message_name = "msg_" + message_name
+ writer.header.writeln("void (*" + message_name + ")(SpiceMarshaller *m, %s *msg" % message.c_type() + names_args + ");")
+ else:
writer.header.writeln("void " + function_name + "(SpiceMarshaller *m, %s *msg" % message.c_type() + names_args + ");")
scope = writer.function(function_name,
@@ -378,11 +390,15 @@ def write_message_marshaller(writer, message, private):
writer.end_block()
if message.has_attr("ifdef"):
writer.endif(message.attributes["ifdef"][0])
+ writer.header.endif(message.attributes["ifdef"][0])
+
writer.newline()
return function_name
def write_protocol_marshaller(writer, proto, is_server, private_marshallers):
functions = {}
+ if private_marshallers:
+ writer.header.begin_block("typedef struct")
for c in proto.channels:
channel = c.channel_type
if channel.has_attr("ifdef"):
@@ -406,6 +422,12 @@ def write_protocol_marshaller(writer, proto, is_server, private_marshallers):
writer.header.endif(channel.attributes["ifdef"][0])
if private_marshallers:
+ writer.header.end_block(newline=False)
+ writer.header.writeln(" SpiceMessageMarshallers;")
+ writer.header.newline()
+ writer.header.statement("SpiceMessageMarshallers *spice_message_marshallers_get" + writer.public_prefix+"(void)")
+ writer.header.newline()
+
scope = writer.function("spice_message_marshallers_get" + writer.public_prefix,
"SpiceMessageMarshallers *",
"void")
@@ -426,4 +448,8 @@ def write_protocol_marshaller(writer, proto, is_server, private_marshallers):
writer.newline()
def write_trailer(writer):
+ writer.header.newline()
+ writer.header.writeln("SPICE_END_DECLS")
+ writer.header.newline()
+
writer.header.writeln("#endif")