Support extra prefix in code generators

This is require when we add a new spice.proto for the old (major 1)
protocol description.
This commit is contained in:
Alexander Larsson 2010-06-22 16:01:57 +02:00
parent 36fd22a9db
commit c621b2bdf1
4 changed files with 11 additions and 6 deletions

View File

@ -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;

View File

@ -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)")

View File

@ -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()

View File

@ -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")