From c621b2bdf14bbc596ec90e917a2c40fa8dc8a4e8 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 22 Jun 2010 16:01:57 +0200 Subject: Support extra prefix in code generators This is require when we add a new spice.proto for the old (major 1) protocol description. --- python_modules/codegen.py | 1 + python_modules/demarshal.py | 10 +++++----- python_modules/marshal.py | 2 +- spice_codegen.py | 4 ++++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/python_modules/codegen.py b/python_modules/codegen.py index 5bb659ac..af6636b0 100644 --- a/python_modules/codegen.py +++ b/python_modules/codegen.py @@ -113,6 +113,7 @@ class CodeWriter: writer.at_line_start = self.at_line_start writer.generated = self.generated writer.options = self.options + writer.public_prefix = self.public_prefix return writer; diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py index b1c41354..8d86e84b 100644 --- a/python_modules/demarshal.py +++ b/python_modules/demarshal.py @@ -966,9 +966,9 @@ def write_channel_parser(writer, channel, server): def write_get_channel_parser(writer, channel_parsers, max_channel, is_server): writer.newline() if is_server: - function_name = "spice_get_server_channel_parser" + function_name = "spice_get_server_channel_parser" + writer.public_prefix else: - function_name = "spice_get_client_channel_parser" + function_name = "spice_get_client_channel_parser" + writer.public_prefix scope = writer.function(function_name, "spice_parse_channel_func_t", @@ -1015,15 +1015,15 @@ def write_full_protocol_parser(writer, is_server): function_name = "spice_parse_msg" else: function_name = "spice_parse_reply" - scope = writer.function(function_name, + scope = writer.function(function_name + writer.public_prefix, "uint8_t *", "uint8_t *message_start, uint8_t *message_end, uint32_t channel, uint16_t message_type, int minor, size_t *size_out, message_destructor_t *free_message") scope.variable_def("spice_parse_channel_func_t", "func" ) if is_server: - writer.assign("func", "spice_get_server_channel_parser(channel, NULL)") + writer.assign("func", "spice_get_server_channel_parser%s(channel, NULL)" % writer.public_prefix) else: - writer.assign("func", "spice_get_client_channel_parser(channel, NULL)") + writer.assign("func", "spice_get_client_channel_parser%s(channel, NULL)" % writer.public_prefix) with writer.if_block("func != NULL"): writer.statement("return func(message_start, message_end, message_type, minor, size_out, free_message)") diff --git a/python_modules/marshal.py b/python_modules/marshal.py index 4279cf0d..76081a99 100644 --- a/python_modules/marshal.py +++ b/python_modules/marshal.py @@ -360,7 +360,7 @@ def write_protocol_marshaller(writer, proto, is_server, private_marshallers): functions[f] = True if private_marshallers: - scope = writer.function("spice_message_marshallers_get", + scope = writer.function("spice_message_marshallers_get" + writer.public_prefix, "SpiceMessageMarshallers *", "void") writer.writeln("static SpiceMessageMarshallers marshallers = {NULL};").newline() diff --git a/spice_codegen.py b/spice_codegen.py index 00342500..1d2314a0 100755 --- a/spice_codegen.py +++ b/spice_codegen.py @@ -113,6 +113,8 @@ parser.add_option("-k", "--keep-identical-file", parser.add_option("-i", "--include", action="append", dest="includes", metavar="FILE", help="Include FILE in generated code") +parser.add_option("--prefix", dest="prefix", + help="set public symbol prefix", default="") (options, args) = parser.parse_args() @@ -134,6 +136,8 @@ writer = codegen.CodeWriter() writer.header = codegen.CodeWriter() writer.set_option("source", os.path.basename(proto_file)) +writer.public_prefix = options.prefix + if options.assert_on_error: writer.set_option("assert_on_error") -- cgit