[Spice-commits] 5 commits - python_modules/demarshal.py python_modules/ptypes.py

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 20 17:46:34 UTC 2019


 python_modules/demarshal.py |    6 ++++--
 python_modules/ptypes.py    |    8 +++++---
 2 files changed, 9 insertions(+), 5 deletions(-)

New commits:
commit a5de31bc8af4923b9f2a5bbd1c766ebd1066b4b0
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Feb 18 03:22:02 2019 +0000

    codegen: Check wrong attribute
    
    @ptr_array is supposed to change the destination to an array
    of pointer to items. This for a raw buffer does not make sense
    but check if user specifies this combination.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 68532a9..e59521c 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -810,6 +810,8 @@ def write_array_parser(writer, member, nelements, array, dest, scope):
         at_end = True
 
     if element_type == ptypes.uint8 or element_type == ptypes.int8:
+        if array.has_attr("ptr_array"):
+            raise Exception("Attribute ptr_array not supported for arrays of int8/uint8")
         writer.statement("memcpy(%s, in, %s)" % (array_start, nelements))
         writer.increment("in", nelements)
         if at_end:
commit 7462c171e1717e3bd2b84c04a8d8c4c12ecb23fb
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Jun 21 22:54:47 2018 +0100

    codegen: Fix c_type result for TypeAlias
    
    c_type() method is supposed to return the type to use for
    C structure field. But the name is not a C type but a
    protocol name.
    Return the type name of the aliased type (for instance
    uint32_t for a uint32 type).
    This does not change the generated code.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 162c4d7..da148e8 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -246,7 +246,7 @@ class TypeAlias(Type):
     def c_type(self):
         if self.has_attr("ctype"):
             return self.attributes["ctype"][0]
-        return self.name
+        return self.the_type.c_type()
 
 class EnumBaseType(Type):
     def is_enum(self):
commit 53c0c5a665bb32698de9545cbdf0f496f0cfe06b
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Feb 18 15:26:55 2019 +0000

    codegen: Reduce indentation
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 3875970..162c4d7 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -920,8 +920,7 @@ class MessageType(ContainerType):
                 channelname = ""
             if cm.is_server:
                 return codegen.prefix_camel("Msg", channelname, cm.name)
-            else:
-                return codegen.prefix_camel("Msgc", channelname, cm.name)
+            return codegen.prefix_camel("Msgc", channelname, cm.name)
         else:
             return codegen.prefix_camel("Msg", self.name)
 
commit 7fa8bda27502d7b810d30de350253eb31c7b5d10
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Feb 18 13:16:37 2019 +0000

    codegen: Use a better type for pointer converted to integer
    
    Although on the platform we support size_t and uintptr_t are
    the same, on some platform the size_t can (in theory) be smaller
    than the necessary integer to store a pointer.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 36213b1..68532a9 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -847,7 +847,7 @@ def write_array_parser(writer, member, nelements, array, dest, scope):
                     write_container_parser(writer, element_type, dest2)
                 if array.has_attr("ptr_array"):
                     writer.comment("Align ptr_array element to 4 bytes").newline()
-                    writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 4)")
+                    writer.assign("end", "(uint8_t *)SPICE_ALIGN((uintptr_t)end, 4)")
 
 def write_parse_pointer_core(writer, target_type, offset, at_end, dest, member_name, scope):
     writer.assign("ptr_info[n_ptr].offset", offset)
@@ -968,7 +968,7 @@ def write_ptr_info_check(writer):
                 writer.assign("*%s" % dest, "NULL")
             with writer.block(" else"):
                 writer.comment("Align to 32 bit").newline()
-                writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 4)")
+                writer.assign("end", "(uint8_t *)SPICE_ALIGN((uintptr_t)end, 4)")
                 writer.assign("*%s" % dest, "(void *)end")
                 writer.assign("end", "%s(message_start, message_end, end, &ptr_info[%s])" % (function, index))
                 writer.error_check("end == NULL")
commit 7f6c55790bc9e32e4051c9a2d981ebee9927203c
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Feb 18 03:22:15 2019 +0000

    codegen: Document ptr_array attribute
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index c548a28..3875970 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -55,6 +55,9 @@ valid_attributes=set([
     'nonnull',
     # this flag member contains only a single flag
     'unique_flag',
+    # represent array as an array of pointers (in the C structure)
+    # for instance a "Type name[size] @ptr_array" in the protocol
+    # will be stored in a "Type *name[0]" field in the C structure
     'ptr_array',
     'outvar',
     # C structure has an anonymous member (used in switch)


More information about the Spice-commits mailing list