summaryrefslogtreecommitdiffstats
path: root/python_modules
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-06-22 16:03:34 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2012-03-20 15:25:44 +0100
commitee944c8314287a1037b9ede077583b1cec31ea07 (patch)
treed009ed0eed6899b9f9023dad61b40f4ddfd7dd5b /python_modules
parent9f3a36f3f939c14da4e2fa1f98f3ebfd50dcf9c7 (diff)
downloadspice-protocol-ee944c8314287a1037b9ede077583b1cec31ea07.tar.gz
spice-protocol-ee944c8314287a1037b9ede077583b1cec31ea07.tar.xz
spice-protocol-ee944c8314287a1037b9ede077583b1cec31ea07.zip
Add support for @virtual markup in spice protocol
This means the member is not sent on the network at all. Instead its initialized to the attribute argument when demarshalled. This is useful for backwards compatibility support.
Diffstat (limited to 'python_modules')
-rw-r--r--python_modules/demarshal.py7
-rw-r--r--python_modules/marshal.py3
-rw-r--r--python_modules/ptypes.py4
3 files changed, 14 insertions, 0 deletions
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index eee659f..a0697a9 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -400,6 +400,9 @@ def write_validate_item(writer, container, item, scope, parent_scope, start,
def write_validate_member(writer, container, member, parent_scope, start,
want_nw_size, want_mem_size, want_extra_size):
+ if member.has_attr("virtual"):
+ return
+
if member.has_minor_attr():
prefix = "if (minor >= %s)" % (member.get_minor_attr())
newline = False
@@ -740,6 +743,10 @@ def write_parse_pointer(writer, t, at_end, dest, member_name, is_64bit, scope):
writer.statement("n_ptr++")
def write_member_parser(writer, container, member, dest, scope):
+ if member.has_attr("virtual"):
+ writer.assign(dest.get_ref(member.name), member.attributes["virtual"][0])
+ return
+
if member.is_switch():
write_switch_parser(writer, container, member, dest, scope)
return
diff --git a/python_modules/marshal.py b/python_modules/marshal.py
index c4bb896..c5afd7c 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -266,6 +266,9 @@ def write_switch_marshaller(writer, container, switch, src, scope):
def write_member_marshaller(writer, container, member, src, scope):
if member.has_attr("outvar"):
writer.out_prefix = "%s_%s" % (member.attributes["outvar"][0], writer.out_prefix)
+ if member.has_attr("virtual"):
+ writer.comment("Don't marshall @virtual %s" % member.name).newline()
+ return
if member.has_attr("nomarshal"):
writer.comment("Don't marshall @nomarshal %s" % member.name).newline()
return
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index fe8a321..101538c 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -518,9 +518,13 @@ class Member(Containee):
return self.has_end_attr()
def is_fixed_nw_size(self):
+ if self.has_attr("virtual"):
+ return True
return self.member_type.is_fixed_nw_size()
def get_fixed_nw_size(self):
+ 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()