[Spice-commits] 4 commits - common/client_demarshallers.h docs/spice_protocol.txt python_modules/demarshal.py python_modules/marshal.py python_modules/ptypes.py

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Oct 15 10:03:18 UTC 2018


 common/client_demarshallers.h |    1 
 docs/spice_protocol.txt       |   16 ---------
 python_modules/demarshal.py   |   71 ++++++------------------------------------
 python_modules/marshal.py     |   12 -------
 python_modules/ptypes.py      |   62 ------------------------------------
 5 files changed, 11 insertions(+), 151 deletions(-)

New commits:
commit 87493929b4b20cf45cd031f9af27457012a93b38
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Oct 11 10:51:29 2018 +0100

    client_demarshallers: Remove SPICE protocol 1 declaration
    
    spice_get_server_channel_parser1 function was removed.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/common/client_demarshallers.h b/common/client_demarshallers.h
index af095a0..43c7e7d 100644
--- a/common/client_demarshallers.h
+++ b/common/client_demarshallers.h
@@ -27,7 +27,6 @@ typedef uint8_t * (*spice_parse_channel_func_t)(uint8_t *message_start, uint8_t
 						size_t *size_out, message_destructor_t *free_message);
 
 spice_parse_channel_func_t spice_get_server_channel_parser(uint32_t channel, unsigned int *max_message_type);
-spice_parse_channel_func_t spice_get_server_channel_parser1(uint32_t channel, unsigned int *max_message_type);
 
 SPICE_END_DECLS
 
commit ddfb8807c6a981cf55ab6c8f302c81d7821d8557
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Sep 28 14:14:11 2018 +0100

    codegen: Remove minor attribute
    
    The idea in version 1 of the protocol was to extend it using the minor
    version. However this was replaced by the usage of capabilities and the
    minor attribute (which was not much used in version 1) was abandoned in
    version 2.
    This patch create a big difference in the code generated but only because
    the minor version was passed between all possible functions as argument.
    Note that exported functions retain the minor argument for compatibility
    reasons.
    The demarshaller code export directly spice_get_client_channel_parser or
    spice_get_server_channel_parser functions which returns internal module
    functions which parse message of specific channels.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/docs/spice_protocol.txt b/docs/spice_protocol.txt
index 421393d..b205743 100644
--- a/docs/spice_protocol.txt
+++ b/docs/spice_protocol.txt
@@ -445,11 +445,6 @@ zero
 
 TODO
 
-minor
-~~~~~
-
-TODO
-
 virtual
 ~~~~~~~
 
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 5209272..6fe3c66 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -92,8 +92,8 @@ def write_parser_helpers(writer):
     writer.newline()
     writer.statement("typedef struct PointerInfo PointerInfo")
     writer.statement("typedef void (*message_destructor_t)(uint8_t *message)")
-    writer.statement("typedef uint8_t * (*parse_func_t)(uint8_t *message_start, uint8_t *message_end, uint8_t *struct_data, PointerInfo *ptr_info, int minor)")
-    writer.statement("typedef uint8_t * (*parse_msg_func_t)(uint8_t *message_start, uint8_t *message_end, int minor, size_t *size_out, message_destructor_t *free_message)")
+    writer.statement("typedef uint8_t * (*parse_func_t)(uint8_t *message_start, uint8_t *message_end, uint8_t *struct_data, PointerInfo *ptr_info)")
+    writer.statement("typedef uint8_t * (*parse_msg_func_t)(uint8_t *message_start, uint8_t *message_end, size_t *size_out, message_destructor_t *free_message)")
     writer.statement("typedef uint8_t * (*spice_parse_channel_func_t)(uint8_t *message_start, uint8_t *message_end, uint16_t message_type, int minor, size_t *size_out, message_destructor_t *free_message)")
 
     writer.newline()
@@ -216,7 +216,7 @@ def write_validate_struct_function(writer, struct):
 
     writer.set_is_generated("validator", validate_function)
     writer = writer.function_helper()
-    scope = writer.function(validate_function, "static intptr_t", "uint8_t *message_start, uint8_t *message_end, uint64_t offset, SPICE_GNUC_UNUSED int minor")
+    scope = writer.function(validate_function, "static intptr_t", "uint8_t *message_start, uint8_t *message_end, uint64_t offset")
     scope.variable_def("uint8_t *", "start = message_start + offset")
     scope.variable_def("SPICE_GNUC_UNUSED uint8_t *", "pos")
     scope.variable_def("uint64_t", "mem_size", "nw_size")
@@ -301,7 +301,7 @@ def write_validate_pointer_item(writer, container, item, scope, parent_scope, st
 
         elif target_type.is_struct():
             validate_function = write_validate_struct_function(writer, target_type)
-            writer.assign("ptr_size", "%s(message_start, message_end, %s, minor)" % (validate_function, v))
+            writer.assign("ptr_size", "%s(message_start, message_end, %s)" % (validate_function, v))
             writer.error_check("ptr_size < 0")
 
             if want_extra_size:
@@ -512,12 +512,8 @@ def write_validate_member(writer, mprefix, container, member, parent_scope, star
     if member.has_attr("virtual"):
         return
 
-    if member.has_minor_attr():
-        prefix = "if (minor >= %s)" % (member.get_minor_attr())
-        newline = False
-    else:
-        prefix = ""
-        newline = True
+    prefix = ""
+    newline = True
     item = MemberItemInfo(member, mprefix, container, start)
     with writer.block(prefix, newline=newline, comment=member.name) as scope:
         if member.is_switch():
@@ -527,24 +523,6 @@ def write_validate_member(writer, mprefix, container, member, parent_scope, star
             write_validate_item(writer, container, item, scope, parent_scope, start,
                                 want_nw_size, want_mem_size, want_extra_size)
 
-    if member.has_minor_attr():
-        with writer.block(" else", comment = "minor < %s" % (member.get_minor_attr())):
-            if member.is_array():
-                nelements = "%s__nelements" %(item.prefix)
-                writer.assign(nelements, 0)
-            if want_nw_size:
-                writer.assign(item.nw_size(), 0)
-
-            if want_mem_size:
-                if member.is_fixed_sizeof():
-                    writer.assign(item.mem_size(), member.sizeof())
-                elif member.is_array():
-                    writer.assign(item.mem_size(), 0)
-                else:
-                    raise NotImplementedError("TODO minor check for non-constant items")
-
-            assert not want_extra_size
-
 def write_validate_container(writer, prefix, container, start, parent_scope, want_nw_size, want_mem_size, want_extra_size):
     def prefix_m(prefix, m):
         name = m.name
@@ -782,7 +760,7 @@ def write_parse_ptr_function(writer, target_type):
     writer.set_is_generated("parser", parse_function)
 
     writer = writer.function_helper()
-    scope = writer.function(parse_function, "static uint8_t *", "uint8_t *message_start, SPICE_GNUC_UNUSED uint8_t *message_end, uint8_t *struct_data, PointerInfo *this_ptr_info, SPICE_GNUC_UNUSED int minor")
+    scope = writer.function(parse_function, "static uint8_t *", "uint8_t *message_start, SPICE_GNUC_UNUSED uint8_t *message_end, uint8_t *struct_data, PointerInfo *this_ptr_info")
     scope.variable_def("uint8_t *", "in = message_start + this_ptr_info->offset")
     scope.variable_def("uint8_t *", "end")
 
@@ -977,24 +955,7 @@ def write_member_parser(writer, container, member, dest, scope):
 def write_container_parser(writer, container, dest):
     with dest.declare(writer) as scope:
         for m in container.members:
-            if m.has_minor_attr():
-                writer.begin_block("if (minor >= %s)" % m.get_minor_attr())
             write_member_parser(writer, container, m, dest, scope)
-            if m.has_minor_attr():
-                # We need to zero out the fixed part of all optional fields
-                if not m.member_type.is_array():
-                    writer.end_block(newline=False)
-                    writer.begin_block(" else")
-                    # TODO: This is not right for fields that don't exist in the struct
-                    if m.has_attr("zero"):
-                        pass
-                    elif m.member_type.is_primitive():
-                        writer.assign(dest.get_ref(m.name), "0")
-                    elif m.is_fixed_sizeof():
-                        writer.statement("memset ((char *)&%s, 0, %s)" % (dest.get_ref(m.name), m.sizeof()))
-                    else:
-                        raise NotImplementedError("TODO Clear optional dynamic fields")
-                writer.end_block()
 
 def write_ptr_info_check(writer):
     writer.newline()
@@ -1009,7 +970,7 @@ def write_ptr_info_check(writer):
                 writer.comment("Align to 32 bit").newline()
                 writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 4)")
                 writer.assign("*%s" % dest, "(void *)end")
-                writer.assign("end", "%s(message_start, message_end, end, &ptr_info[%s], minor)" % (function, index))
+                writer.assign("end", "%s(message_start, message_end, end, &ptr_info[%s])" % (function, index))
                 writer.error_check("end == NULL")
     writer.newline()
 
@@ -1037,7 +998,7 @@ def write_msg_parser(writer, message):
         writer.ifdef(message.attributes["ifdef"][0])
     parent_scope = writer.function(function_name,
                                    "uint8_t *",
-                                   "uint8_t *message_start, uint8_t *message_end, SPICE_GNUC_UNUSED int minor, size_t *size, message_destructor_t *free_message", True)
+                                   "uint8_t *message_start, uint8_t *message_end, size_t *size, message_destructor_t *free_message", True)
     parent_scope.variable_def("SPICE_GNUC_UNUSED uint8_t *", "pos")
     parent_scope.variable_def("uint8_t *", "start = message_start")
     parent_scope.variable_def("uint8_t *", "data = NULL")
@@ -1160,7 +1121,7 @@ def write_channel_parser(writer, channel, server):
     for r in ranges:
         d = d + 1
         with writer.if_block("message_type >= %d && message_type < %d" % (r[0], r[1]), d > 1, False):
-            writer.statement("return funcs%d[message_type-%d](message_start, message_end, minor, size_out, free_message)" % (d, r[0]))
+            writer.statement("return funcs%d[message_type-%d](message_start, message_end, size_out, free_message)" % (d, r[0]))
     writer.newline()
 
     writer.statement("return NULL")
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index f39f044..c548a28 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -15,46 +15,6 @@ def lookup_type(name):
 def get_named_types():
     return _types
 
-class FixedSize:
-    def __init__(self, val = 0, minor = 0):
-        if isinstance(val, FixedSize):
-            self.vals = val.vals
-        else:
-            self.vals = [0] * (minor + 1)
-            self.vals[minor] = val
-
-    def __add__(self, other):
-        if isinstance(other, int):
-            other = FixedSize(other)
-
-        new = FixedSize()
-        l = max(len(self.vals), len(other.vals))
-        shared = min(len(self.vals), len(other.vals))
-
-        new.vals = [0] * l
-
-        for i in range(shared):
-            new.vals[i] = self.vals[i] + other.vals[i]
-
-        for i in range(shared,len(self.vals)):
-            new.vals[i] = self.vals[i]
-
-        for i in range(shared,len(other.vals)):
-            new.vals[i] = new.vals[i] + other.vals[i]
-
-        return new
-
-    def __radd__(self, other):
-        return self.__add__(other)
-
-    def __str__(self):
-        s = "%d" % (self.vals[0])
-
-        for i in range(1,len(self.vals)):
-            if self.vals[i] > 0:
-                s = s + " + ((minor >= %d)?%d:0)" % (i, self.vals[i])
-        return s
-
 # Some attribute are propagated from member to the type as they really
 # are part of the type definition, rather than the member. This applies
 # only to attributes that affect pointer or array attributes, as these
@@ -107,8 +67,6 @@ valid_attributes=set([
     # when marshalling, a zero field is written to the network
     # when demarshalling, the field is read from the network and discarded
     'zero',
-    # specify minor version required for these members
-    'minor',
     # this attribute does not exist on the network, fill just structure with the value
     'virtual',
 ])
@@ -119,7 +77,6 @@ attributes_with_arguments=set([
     'as_ptr',
     'outvar',
     'ifdef',
-    'minor',
     'virtual',
 ])
 
@@ -587,15 +544,9 @@ class Containee:
             raise Exception('attribute %s not expected' % name)
         return name in self.attributes
 
-    def has_minor_attr(self):
-        return self.has_attr("minor")
-
     def has_end_attr(self):
         return self.has_attr("end")
 
-    def get_minor_attr(self):
-        return self.attributes["minor"][0]
-
 class Member(Containee):
     def __init__(self, name, member_type, attribute_list):
         Containee.__init__(self)
@@ -635,9 +586,6 @@ class Member(Containee):
         if self.has_attr("virtual"):
             return 0
         size = self.member_type.get_fixed_nw_size()
-        if self.has_minor_attr():
-            minor = self.get_minor_attr()
-            size = FixedSize(size, minor)
         return size
 
     def contains_extra_size(self):
commit 8a68e67afa48370adfae846b71dc4b86f70c7c0b
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Sep 28 14:22:16 2018 +0100

    codegen: Remove fixedsize attribute
    
    This attribute was used only in SPICE version 1.
    The intention was use fixed size for switch type in the protocol.
    However this does not bring any improvement, just increase network
    bytes used.
    Generated code does not change.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/docs/spice_protocol.txt b/docs/spice_protocol.txt
index 18b636f..421393d 100644
--- a/docs/spice_protocol.txt
+++ b/docs/spice_protocol.txt
@@ -454,9 +454,3 @@ virtual
 ~~~~~~~
 
 TODO
-
-fixedsize
-~~~~~~~~~
-
-TODO
-
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 541137e..5209272 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -729,10 +729,6 @@ def write_switch_parser(writer, container, switch, dest, scope):
     var = container.lookup_member(switch.variable)
     var_type = var.member_type
 
-    if switch.has_attr("fixedsize"):
-        scope.variable_def("uint8_t *", "in_save")
-        writer.assign("in_save", "in")
-
     first = True
     for c in switch.cases:
         check = c.get_check(dest.get_ref(switch.variable), var_type)
@@ -775,9 +771,6 @@ def write_switch_parser(writer, container, switch, dest, scope):
 
     writer.newline()
 
-    if switch.has_attr("fixedsize"):
-        writer.assign("in", "in_save + %s" % switch.get_fixed_nw_size())
-
 def write_parse_ptr_function(writer, target_type):
     if target_type.is_array():
         parse_function = "parse_array_%s" % target_type.element_type.primitive_type()
diff --git a/python_modules/marshal.py b/python_modules/marshal.py
index 940c925..4e98993 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -289,15 +289,7 @@ def write_switch_marshaller(writer, container, switch, src, scope):
             else:
                 writer.todo("Can't handle type %s" % m.member_type)
 
-            if switch.has_attr("fixedsize"):
-                remaining = switch.get_fixed_nw_size() - t.get_fixed_nw_size()
-                if remaining != 0:
-                    writer.statement("spice_marshaller_reserve_space(m, %s)" % remaining)
-
         first = False
-    if switch.has_attr("fixedsize"):
-        with writer.block(" else"):
-            writer.statement("spice_marshaller_reserve_space(m, %s)" % switch.get_fixed_nw_size())
 
     writer.newline()
 
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 4b74225..f39f044 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -111,9 +111,6 @@ valid_attributes=set([
     'minor',
     # this attribute does not exist on the network, fill just structure with the value
     'virtual',
-    # for a switch this indicates that on network
-    # it will occupy always the same size (maximum size required for all members)
-    'fixedsize',
 ])
 
 attributes_with_arguments=set([
@@ -737,9 +734,6 @@ class Switch(Containee):
         return True
 
     def is_fixed_nw_size(self):
-        if self.has_attr("fixedsize"):
-            return True
-
         size = None
         has_default = False
         for c in self.cases:
commit 979717350d1f6b0d849673ca42505d18261d4bca
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri Sep 28 14:05:45 2018 +0100

    codegen: Remove bytes_count attribute
    
    This attribute was used only in SPICE version 1.
    Its usage was confusing, and was replaced by the simple usage of
    array size.
    Generated code does not change.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/docs/spice_protocol.txt b/docs/spice_protocol.txt
index 53700db..18b636f 100644
--- a/docs/spice_protocol.txt
+++ b/docs/spice_protocol.txt
@@ -450,11 +450,6 @@ minor
 
 TODO
 
-bytes_count
-~~~~~~~~~~~
-
-TODO
-
 virtual
 ~~~~~~~
 
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 5a237a6..541137e 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -940,10 +940,7 @@ def write_member_parser(writer, container, member, dest, scope):
             writer.statement("*(%s *)end = consume_%s(&in)" % (t.c_type(), t.primitive_type()))
             writer.increment("end", t.sizeof())
         else:
-            if member.has_attr("bytes_count"):
-                dest_var = dest.get_ref(member.attributes["bytes_count"][0])
-            else:
-                dest_var = dest.get_ref(member.name)
+            dest_var = dest.get_ref(member.name)
             writer.assign(dest_var, "consume_%s(&in)" % (t.primitive_type()))
         #TODO validate e.g. flags and enums
     elif t.is_array():
diff --git a/python_modules/marshal.py b/python_modules/marshal.py
index 94ff055..940c925 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -321,10 +321,6 @@ def write_member_marshaller(writer, container, member, src, scope):
     elif t.is_primitive():
         if member.has_attr("zero"):
             writer.statement("spice_marshaller_add_%s(m, 0)" % (t.primitive_type()))
-        elif member.has_attr("bytes_count"):
-            var = "%s__ref" % member.name
-            scope.variable_def("void *", var)
-            writer.statement("%s = spice_marshaller_add_%s(m, %s)" % (var, t.primitive_type(), 0))
 
         else:
             writer.statement("spice_marshaller_add_%s(m, %s)" % (t.primitive_type(), src.get_ref(member.name)))
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 91c185d..4b74225 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -109,9 +109,6 @@ valid_attributes=set([
     'zero',
     # specify minor version required for these members
     'minor',
-    # this member contains the byte count for an array.
-    # the argument is the member name for item count (not bytes)
-    'bytes_count',
     # this attribute does not exist on the network, fill just structure with the value
     'virtual',
     # for a switch this indicates that on network
@@ -126,7 +123,6 @@ attributes_with_arguments=set([
     'outvar',
     'ifdef',
     'minor',
-    'bytes_count',
     'virtual',
 ])
 


More information about the Spice-commits mailing list