[Spice-devel] [PATCH spice-common 9/9] codegen: Rename --prefix parameter to --suffix

Frediano Ziglio fziglio at redhat.com
Sun Mar 3 19:10:30 UTC 2019


The option is used to add a suffix to public functions, not a
prefix.
Currently the option is not used (it was used to generate protocol
1 code).

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 python_modules/codegen.py   |  2 +-
 python_modules/demarshal.py | 10 +++++-----
 python_modules/marshal.py   |  4 ++--
 spice_codegen.py            |  8 ++++----
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/python_modules/codegen.py b/python_modules/codegen.py
index f7a2048..bfb2351 100644
--- a/python_modules/codegen.py
+++ b/python_modules/codegen.py
@@ -117,7 +117,7 @@ class CodeWriter:
         writer.index_type = self.index_type
         writer.generated = self.generated
         writer.options = self.options
-        writer.public_prefix = self.public_prefix
+        writer.public_suffix = self.public_suffix
 
         return writer
 
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index e59521c..d3147b7 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -1136,9 +1136,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" + writer.public_prefix
+        function_name = "spice_get_server_channel_parser" + writer.public_suffix
     else:
-        function_name = "spice_get_client_channel_parser" + writer.public_prefix
+        function_name = "spice_get_client_channel_parser" + writer.public_suffix
 
     scope = writer.function(function_name,
                             "spice_parse_channel_func_t",
@@ -1195,15 +1195,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 + writer.public_prefix,
+    scope = writer.function(function_name + writer.public_suffix,
                             "uint8_t *",
                             "uint8_t *message_start, uint8_t *message_end, uint32_t channel, uint16_t message_type, SPICE_GNUC_UNUSED 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%s(channel, NULL)" % writer.public_prefix)
+        writer.assign("func", "spice_get_server_channel_parser%s(channel, NULL)" % writer.public_suffix)
     else:
-        writer.assign("func", "spice_get_client_channel_parser%s(channel, NULL)" % writer.public_prefix)
+        writer.assign("func", "spice_get_client_channel_parser%s(channel, NULL)" % writer.public_suffix)
 
     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 74f3a54..a09b614 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -412,10 +412,10 @@ def write_protocol_marshaller(writer, proto, is_server, 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.statement("SpiceMessageMarshallers *spice_message_marshallers_get" + writer.public_suffix+"(void)")
         writer.header.newline()
 
-        scope = writer.function("spice_message_marshallers_get" +  writer.public_prefix,
+        scope = writer.function("spice_message_marshallers_get" +  writer.public_suffix,
                                 "SpiceMessageMarshallers *",
                                 "void")
         writer.writeln("static SpiceMessageMarshallers marshallers = {NULL};").newline()
diff --git a/spice_codegen.py b/spice_codegen.py
index e518686..4f096a2 100755
--- a/spice_codegen.py
+++ b/spice_codegen.py
@@ -169,8 +169,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="")
+parser.add_option("--suffix", dest="suffix",
+                  help="set public symbol suffix", default="")
 parser.add_option("--license", dest="license",
                   help="license to use for generated file(s) (LGPL/BSD)", default="LGPL")
 parser.add_option("--generated-header", dest="generated_header", metavar="FILE",
@@ -284,7 +284,7 @@ current:
 
 def generate_declarations():
     writer = codegen.CodeWriter()
-    writer.public_prefix = options.prefix
+    writer.public_suffix = options.suffix
     writer.write(license)
 
     # all types
@@ -302,7 +302,7 @@ def generate_declarations():
 if options.generated_declaration_file:
     generate_declarations()
 
-writer.public_prefix = options.prefix
+writer.public_suffix = options.suffix
 
 writer.writeln("/* this is a file autogenerated by spice_codegen.py */")
 writer.write(license)
-- 
2.20.1



More information about the Spice-devel mailing list