[Spice-commits] 4 commits - common/marshaller.c python_modules/ptypes.py
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed May 23 09:34:13 UTC 2018
common/marshaller.c | 4 +-
python_modules/ptypes.py | 78 +++++++++++++++++++++++------------------------
2 files changed, 41 insertions(+), 41 deletions(-)
New commits:
commit b17894e764a57e77537d0d450abf82ac0b6af9c6
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon May 14 23:12:40 2018 +0100
Check for messages with duplicate values inside a channel
Make sure there are not 2 messages with the same value in the
same channel.
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 916ba50..056e984 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -1028,6 +1028,10 @@ class ChannelType(Type):
self.messages_byname = messages_byname.copy()
self.count = 1
+ self.messages_byvalue = {}
+ for m in self.messages:
+ self.messages_byvalue[m.value] = m
+
if self.base is None:
server_info = MessagesInfo(True)
client_info = MessagesInfo(False)
@@ -1058,6 +1062,10 @@ class ChannelType(Type):
if m.name in info.messages_byname:
raise Exception("Duplicated message name '%s' in channel '%s'" % (m.name, self.name))
info.messages_byname[m.name] = m
+ if m.value in info.messages_byvalue:
+ raise Exception("Duplicated message value %d between '%s' and '%s' in channel '%s'" % (
+ m.value, info.messages_byvalue[m.value].name, m.name, self.name))
+ info.messages_byvalue[m.value] = m
self.server_messages = server_info.messages
self.server_messages_byname = server_info.messages_byname
commit e2f7a9235f111fa07b4978b1fe809087c4dcc2f4
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon May 14 23:12:03 2018 +0100
Check for messages with duplicate names inside a channel
Make sure there are not 2 messages with the same name in the
same channel.
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 631739e..916ba50 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -1055,6 +1055,8 @@ class ChannelType(Type):
m.value = info.count
info.count = m.value + 1
info.messages.append(m)
+ if m.name in info.messages_byname:
+ raise Exception("Duplicated message name '%s' in channel '%s'" % (m.name, self.name))
info.messages_byname[m.name] = m
self.server_messages = server_info.messages
commit abdef4fd2a4be5c5d363cda2b2838a1f7cc4899d
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon May 14 23:09:53 2018 +0100
codegen: Remove duplicate client and server code from ChannelType::resolve
Code that handled client and server messages check was the same, just
changed some variable names.
Instead use a class to store same information and reuse the code.
This allows easier extension of the 2 path of code.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Lukáš Hrázký <lhrazky at redhat.com>
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 0f6d8d6..631739e 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -1021,56 +1021,46 @@ class ChannelType(Type):
return self.server_messages_byname[name]
def resolve(self):
- if self.base != None:
+ class MessagesInfo:
+ def __init__(self, is_server, messages=[], messages_byname={}):
+ self.is_server = is_server
+ self.messages = messages[:]
+ self.messages_byname = messages_byname.copy()
+ self.count = 1
+
+ if self.base is None:
+ server_info = MessagesInfo(True)
+ client_info = MessagesInfo(False)
+ else:
self.base = self.base.resolve()
- server_messages = self.base.server_messages[:]
- server_messages_byname = self.base.server_messages_byname.copy()
- client_messages = self.base.client_messages[:]
- client_messages_byname = self.base.client_messages_byname.copy()
+ server_info = MessagesInfo(True, self.base.server_messages,
+ self.base.server_messages_byname)
+ client_info = MessagesInfo(False, self.base.client_messages,
+ self.base.client_messages_byname)
# Set default member_name, FooChannel -> foo
self.member_name = self.name[:-7].lower()
- else:
- server_messages = []
- server_messages_byname = {}
- client_messages = []
- client_messages_byname = {}
- server_count = 1
- client_count = 1
-
- server = True
+ info = server_info
for m in self.members:
if m == "server":
- server = True
+ info = server_info
elif m == "client":
- server = False
- elif server:
- m.is_server = True
- m = m.resolve(self)
- if m.value:
- server_count = m.value + 1
- else:
- m.value = server_count
- server_count = server_count + 1
- server_messages.append(m)
- server_messages_byname[m.name] = m
+ info = client_info
else:
- m.is_server = False
+ m.is_server = info.is_server
m = m.resolve(self)
- if m.value:
- client_count = m.value + 1
- else:
- m.value = client_count
- client_count = client_count + 1
- client_messages.append(m)
- client_messages_byname[m.name] = m
-
- self.server_messages = server_messages
- self.server_messages_byname = server_messages_byname
- self.client_messages = client_messages
- self.client_messages_byname = client_messages_byname
+ if not m.value:
+ m.value = info.count
+ info.count = m.value + 1
+ info.messages.append(m)
+ info.messages_byname[m.name] = m
+
+ self.server_messages = server_info.messages
+ self.server_messages_byname = server_info.messages_byname
+ self.client_messages = client_info.messages
+ self.client_messages_byname = client_info.messages_byname
return self
commit 78a17ba00a0a321cba58b650b3827dc66a855acf
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri May 18 20:09:04 2018 +0100
marshaller: Remove initial underscore from static function
This is the only function starting with an underscore, looks
out of style.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
diff --git a/common/marshaller.c b/common/marshaller.c
index 80cedb7..b55b568 100644
--- a/common/marshaller.c
+++ b/common/marshaller.c
@@ -270,7 +270,7 @@ static size_t remaining_buffer_size(SpiceMarshallerData *d)
return MARSHALLER_BUFFER_SIZE - d->current_buffer_position;
}
-static void _reserve_space_free_data(uint8_t *data, SPICE_GNUC_UNUSED void *opaque)
+static void reserve_space_free_data(uint8_t *data, SPICE_GNUC_UNUSED void *opaque)
{
free(data);
}
@@ -313,7 +313,7 @@ uint8_t *spice_marshaller_reserve_space(SpiceMarshaller *m, size_t size)
/* Large item, allocate by itself */
item->data = (uint8_t *)spice_malloc(size);
item->len = size;
- item->free_data = _reserve_space_free_data;
+ item->free_data = reserve_space_free_data;
item->opaque = NULL;
} else {
/* Use next buffer */
More information about the Spice-commits
mailing list