[Spice-commits] 6 commits - client/Makefile.am client/windows python_modules/demarshal.py python_modules/marshal.py python_modules/ptypes.py spice_codegen.py spice.proto
Alexander Larsson
alexl at kemper.freedesktop.org
Wed Jun 23 07:33:46 PDT 2010
client/Makefile.am | 4 ++--
client/windows/generate1.bat | 4 ++--
python_modules/demarshal.py | 15 ++++++---------
python_modules/marshal.py | 4 ++--
python_modules/ptypes.py | 26 +++++++++++++++++++++-----
spice.proto | 14 ++++++--------
spice_codegen.py | 4 ++++
7 files changed, 43 insertions(+), 28 deletions(-)
New commits:
commit 054c88b1250417d4452fe4f54cdbcc1c4da51616
Author: Alexander Larsson <alexl at redhat.com>
Date: Wed Jun 23 16:30:29 2010 +0200
spice.proto: Don't use @fixedsize for Brush
There is no reason to send the maximum size on the network, that is just
a waste of space most of the time.
diff --git a/spice.proto b/spice.proto
index 240ed05..0d970da 100644
--- a/spice.proto
+++ b/spice.proto
@@ -529,7 +529,7 @@ struct Brush {
uint32 color;
case PATTERN:
Pattern pattern;
- } u @fixedsize;
+ } u;
};
struct QMask {
commit 0c0b4f9e84f43bd94a2241b5b9658a900b4eb437
Author: Alexander Larsson <alexl at redhat.com>
Date: Wed Jun 23 16:20:55 2010 +0200
Don't send zero data item for clips with no data
diff --git a/spice.proto b/spice.proto
index f722e7d..240ed05 100644
--- a/spice.proto
+++ b/spice.proto
@@ -412,9 +412,7 @@ struct Path {
struct Clip {
clip_type type;
switch (type) {
- case NONE:
- uint64 data @zero;
- case RECTS:
+ case RECTS:
ClipRects *data @outvar(cliprects);
case PATH:
Path *data @outvar(clippath);
commit dc8625c7e156a2b1eff16397b4be039ac5da9089
Author: Alexander Larsson <alexl at redhat.com>
Date: Wed Jun 23 16:20:33 2010 +0200
Make pointers 32bit in new protocol format
diff --git a/client/Makefile.am b/client/Makefile.am
index 255787e..7a7420a 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -9,13 +9,13 @@ generated_demarshallers.cpp: $(top_srcdir)/spice.proto
$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --client --include common.h --include messages.h $(top_srcdir)/spice.proto generated_demarshallers.cpp
generated_demarshallers1.cpp: $(top_srcdir)/spice1.proto
- $(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --client --include common.h --include messages.h --prefix 1 $(top_srcdir)/spice1.proto generated_demarshallers1.cpp
+ $(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --client --include common.h --include messages.h --prefix 1 --ptrsize 8 $(top_srcdir)/spice1.proto generated_demarshallers1.cpp
generated_marshallers.cpp: $(top_srcdir)/spice.proto
$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include messages.h --include marshallers.h --client $(top_srcdir)/spice.proto generated_marshallers.cpp
generated_marshallers1.cpp: $(top_srcdir)/spice1.proto
- $(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include messages.h --include marshallers.h --client --prefix 1 $(top_srcdir)/spice1.proto generated_marshallers1.cpp
+ $(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include messages.h --include marshallers.h --client --prefix 1 --ptrsize 8 $(top_srcdir)/spice1.proto generated_marshallers1.cpp
if SUPPORT_GL
GL_SRCS = \
diff --git a/client/windows/generate1.bat b/client/windows/generate1.bat
index d720353..b22eaf1 100644
--- a/client/windows/generate1.bat
+++ b/client/windows/generate1.bat
@@ -1,2 +1,2 @@
-python ..\..\spice_codegen.py -d -c -i common.h -i messages.h --prefix 1 ..\..\spice1.proto ..\generated_demarshallers1.cpp
-python ..\..\spice_codegen.py --generate-marshallers -P --include messages.h --include marshallers.h --client --prefix 1 ..\..\spice1.proto ..\generated_marshallers1.cpp
+python ..\..\spice_codegen.py -d -c -i common.h -i messages.h --prefix 1 --ptrsize 8 ..\..\spice1.proto ..\generated_demarshallers1.cpp
+python ..\..\spice_codegen.py --generate-marshallers -P --include messages.h --include marshallers.h --client --prefix 1 --ptrsize 8 ..\..\spice1.proto ..\generated_marshallers1.cpp
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index a0697a9..0138ebe 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -184,7 +184,7 @@ def write_validate_struct_function(writer, struct):
def write_validate_pointer_item(writer, container, item, scope, parent_scope, start,
want_nw_size, want_mem_size, want_extra_size):
if want_nw_size:
- writer.assign(item.nw_size(), 8)
+ writer.assign(item.nw_size(), item.type.get_fixed_nw_size())
if want_mem_size or want_extra_size:
target_type = item.type.target_type
@@ -636,7 +636,7 @@ def write_switch_parser(writer, container, switch, dest, scope):
if t.is_struct():
write_container_parser(writer, t, dest2)
elif t.is_pointer():
- write_parse_pointer(writer, t, False, dest2, m.name, not m.has_attr("ptr32"), block)
+ write_parse_pointer(writer, t, False, dest2, m.name, block)
elif t.is_primitive():
writer.assign(dest2.get_ref(m.name), "consume_%s(&in)" % (t.primitive_type()))
#TODO validate e.g. flags and enums
@@ -724,12 +724,9 @@ def write_array_parser(writer, nelements, array, dest, scope):
dest2.reuse_scope = array_scope
write_container_parser(writer, element_type, dest2)
-def write_parse_pointer(writer, t, at_end, dest, member_name, is_64bit, scope):
+def write_parse_pointer(writer, t, at_end, dest, member_name, scope):
target_type = t.target_type
- if is_64bit:
- writer.assign("ptr_info[n_ptr].offset", "consume_uint64(&in)")
- else:
- writer.assign("ptr_info[n_ptr].offset", "consume_uint32(&in)")
+ writer.assign("ptr_info[n_ptr].offset", "consume_%s(&in)" % t.primitive_type())
writer.assign("ptr_info[n_ptr].parse", write_parse_ptr_function(writer, target_type))
if at_end:
writer.assign("ptr_info[n_ptr].dest", "end")
@@ -756,9 +753,9 @@ def write_member_parser(writer, container, member, dest, scope):
if t.is_pointer():
if member.has_attr("nocopy"):
writer.comment("Reuse data from network message").newline()
- writer.assign(dest.get_ref(member.name), "(size_t)(message_start + consume_uint64(&in))")
+ writer.assign(dest.get_ref(member.name), "(size_t)(message_start + consume_%s(&in))" % t.primitive_type())
else:
- write_parse_pointer(writer, t, member.has_end_attr(), dest, member.name, not member.has_attr("ptr32"), scope)
+ write_parse_pointer(writer, t, member.has_end_attr(), dest, member.name, scope)
elif t.is_primitive():
if member.has_end_attr():
writer.statement("*(%s *)end = consume_%s(&in)" % (t.c_type(), t.primitive_type()))
diff --git a/python_modules/marshal.py b/python_modules/marshal.py
index c5afd7c..ef1a47c 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -239,7 +239,7 @@ def write_switch_marshaller(writer, container, switch, src, scope):
write_container_marshaller(writer, t, src2)
elif t.is_pointer():
ptr_func = write_marshal_ptr_function(writer, t.target_type)
- writer.assign("*%s_out" % (writer.out_prefix + m.name), "spice_marshaller_get_ptr_submarshaller(m, %s)" % ("0" if m.has_attr("ptr32") else "1"))
+ writer.assign("*%s_out" % (writer.out_prefix + m.name), "spice_marshaller_get_ptr_submarshaller(m, %d)" % (1 if m.get_fixed_nw_size() == 8 else 0))
elif t.is_primitive():
if m.has_attr("zero"):
writer.statement("spice_marshaller_add_%s(m, 0)" % (t.primitive_type()))
@@ -285,7 +285,7 @@ def write_member_marshaller(writer, container, member, src, scope):
# else:
# write_parse_pointer(writer, t, member.has_end_attr(), src, member.name, scope)
ptr_func = write_marshal_ptr_function(writer, t.target_type)
- writer.assign("*%s_out" % (writer.out_prefix + member.name), "spice_marshaller_get_ptr_submarshaller(m, %s)" % ("0" if member.has_attr("ptr32") else "1"))
+ writer.assign("*%s_out" % (writer.out_prefix + member.name), "spice_marshaller_get_ptr_submarshaller(m, %d)" % (1 if member.get_fixed_nw_size() == 8 else 0))
elif t.is_primitive():
if member.has_attr("zero"):
writer.statement("spice_marshaller_add_%s(m, 0)" % (t.primitive_type()))
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 2ee1789..f4126a5 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -4,6 +4,8 @@ import types
_types_by_name = {}
_types = []
+default_pointer_size = 4
+
def type_exists(name):
return _types_by_name.has_key(name)
@@ -426,7 +428,7 @@ class PointerType(Type):
Type.__init__(self)
self.name = None
self.target_type = target_type
- self.pointer_size = 8
+ self.pointer_size = default_pointer_size
def __str__(self):
return "%s*" % (str(self.target_type))
diff --git a/spice_codegen.py b/spice_codegen.py
index 1d2314a..3a9989d 100755
--- a/spice_codegen.py
+++ b/spice_codegen.py
@@ -115,6 +115,8 @@ parser.add_option("-i", "--include",
help="Include FILE in generated code")
parser.add_option("--prefix", dest="prefix",
help="set public symbol prefix", default="")
+parser.add_option("--ptrsize", dest="ptrsize",
+ help="set default pointer size", default="4")
(options, args) = parser.parse_args()
@@ -124,6 +126,8 @@ if len(args) == 0:
if len(args) == 1:
parser.error("No destination file specified")
+ptypes.default_pointer_size = int(options.ptrsize)
+
proto_file = args[0]
dest_file = args[1]
proto = spice_parser.parse(proto_file)
commit 929245bacd8e9f1ba170e019f107738e75a599ad
Author: Alexander Larsson <alexl at redhat.com>
Date: Wed Jun 23 16:18:21 2010 +0200
marshaller: Correctly determine if switches are fixed size
Switches are fixed size only if all cases have the same size *and*
it has a default case or all the valid cases are listed.
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 9141539..2ee1789 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -630,14 +630,22 @@ class Switch(Containee):
return True
size = None
+ has_default = False
for c in self.cases:
+ for v in c.values:
+ if v == None:
+ has_default = True
if not c.member.is_fixed_nw_size():
return False
if size == None:
size = c.member.get_fixed_nw_size()
elif size != c.member.get_fixed_nw_size():
return False
- return True
+ # Fixed size if all elements listed, or has default
+ if has_default:
+ return True
+ key = self.container.lookup_member(self.variable)
+ return len(self.cases) == len(key.member_type.values)
def is_extra_size(self):
return self.has_end_attr()
commit 06fe6a91c2e5eb91ae97b4f3b09c02aa07953768
Author: Alexander Larsson <alexl at redhat.com>
Date: Wed Jun 23 13:37:25 2010 +0200
Fix handling of @ptr32 network size
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 101538c..9141539 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -426,6 +426,7 @@ class PointerType(Type):
Type.__init__(self)
self.name = None
self.target_type = target_type
+ self.pointer_size = 8
def __str__(self):
return "%s*" % (str(self.target_type))
@@ -434,8 +435,8 @@ class PointerType(Type):
self.target_type = self.target_type.resolve()
return self
- def get_fixed_size(self):
- return 8 # offsets are 64bit
+ def set_ptr_size(self, new_size):
+ self.pointer_size = new_size
def is_fixed_nw_size(self):
return True
@@ -444,10 +445,13 @@ class PointerType(Type):
return True
def primitive_type(self):
- return "uint64"
+ if self.pointer_size == 4:
+ return "uint32"
+ else:
+ return "uint64"
def get_fixed_nw_size(self):
- return 8
+ return self.pointer_size
def c_type(self):
return "SPICE_ADDRESS"
@@ -504,6 +508,8 @@ class Member(Containee):
self.container = container
self.member_type = self.member_type.resolve()
self.member_type.register()
+ if self.has_attr("ptr32") and self.member_type.is_pointer():
+ self.member_type.set_ptr_size(4)
return self
def is_primitive(self):
commit 10c16b3c82f179e05360d38c29431115895dcba5
Author: Alexander Larsson <alexl at redhat.com>
Date: Wed Jun 23 12:25:16 2010 +0200
Remove minor markup in unstable protocol as we're resetting minor to 0
diff --git a/spice.proto b/spice.proto
index dbd3dde..f722e7d 100644
--- a/spice.proto
+++ b/spice.proto
@@ -168,11 +168,11 @@ channel MainChannel : BaseChannel {
uint16 sport;
uint32 host_offset;
uint32 host_size;
- pubkey_type pub_key_type @minor(2);
- uint32 pub_key_offset @minor(2);
- uint32 pub_key_size @minor(2);
+ pubkey_type pub_key_type;
+ uint32 pub_key_offset;
+ uint32 pub_key_size;
uint8 host_data[host_size] @end @ctype(uint8_t) @zero_terminated @nomarshal;
- uint8 pub_key_data[pub_key_size] @minor(2) @end @ctype(uint8_t) @zero_terminated @nomarshal;
+ uint8 pub_key_data[pub_key_size] @end @ctype(uint8_t) @zero_terminated @nomarshal;
} @ctype(SpiceMsgMainMigrationBegin) migrate_begin = 101;
Empty migrate_cancel;
More information about the Spice-commits
mailing list