summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-07-19 16:27:42 +0200
committerAlexander Larsson <alexl@redhat.com>2010-07-19 16:28:23 +0200
commite646529d2e72ccd5b25f88adcf2c37f15c601408 (patch)
tree29dbfe2292ff56e642b1dd5bbafb0235c8b26f2e
parent38809803807637336209a89822e12bb5f22148ca (diff)
downloadspice-e646529d2e72ccd5b25f88adcf2c37f15c601408.tar.gz
spice-e646529d2e72ccd5b25f88adcf2c37f15c601408.tar.xz
spice-e646529d2e72ccd5b25f88adcf2c37f15c601408.zip
Don't send CursorHeader if cursor_flags is NONE
-rw-r--r--python_modules/demarshal.py5
-rw-r--r--python_modules/ptypes.py4
-rw-r--r--python_modules/spice_parser.py2
-rw-r--r--spice.proto5
4 files changed, 11 insertions, 5 deletions
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 4aba7b0b..f259ead4 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -708,7 +708,10 @@ def write_switch_parser(writer, container, switch, dest, scope):
if switch.has_end_attr():
dest2 = dest.child_at_end(writer, m.member_type)
elif switch.has_attr("anon"):
- dest2 = dest
+ if t.is_struct() and not m.has_attr("to_ptr"):
+ dest2 = dest.child_sub(m.name)
+ else:
+ dest2 = dest
else:
if t.is_struct():
dest2 = dest.child_sub(switch.name + "." + m.name)
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 59ed8974..0ae57eca 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -591,9 +591,9 @@ class SwitchCase:
if v == None:
return "1"
elif var_type.is_enum():
- checks.append("%s == %s" % (var_cname, var_type.c_enumname_by_name(v)))
+ checks.append("%s == %s" % (var_cname, var_type.c_enumname_by_name(v[1])))
else:
- checks.append("(%s & %s)" % (var_cname, var_type.c_enumname_by_name(v)))
+ checks.append("%s(%s & %s)" % (v[0], var_cname, var_type.c_enumname_by_name(v[1])))
return " || ".join(checks)
def resolve(self, container):
diff --git a/python_modules/spice_parser.py b/python_modules/spice_parser.py
index ac2da8dc..43e930c5 100644
--- a/python_modules/spice_parser.py
+++ b/python_modules/spice_parser.py
@@ -93,7 +93,7 @@ def SPICE_BNF():
variableDef = Group(typeSpec + Optional("*", default=None) + identifier + Optional(arraySizeSpec, default=None) + attributes - semi) \
.setParseAction(parseVariableDef)
- switchCase = Group(Group(OneOrMore(default_.setParseAction(replaceWith(None)) + colon | case_.suppress() + identifier + colon)) + variableDef) \
+ switchCase = Group(Group(OneOrMore(default_.setParseAction(replaceWith(None)) + colon | Group(case_.suppress() + Optional("!", default="") + identifier) + colon)) + variableDef) \
.setParseAction(lambda toks: ptypes.SwitchCase(toks[0][0], toks[0][1]))
switchBody = Group(switch_ + lparen + delimitedList(identifier,delim='.', combine=True) + rparen + lbrace + Group(OneOrMore(switchCase)) + rbrace + identifier + attributes - semi) \
.setParseAction(lambda toks: ptypes.Switch(toks[0][1], toks[0][2], toks[0][3], toks[0][4]))
diff --git a/spice.proto b/spice.proto
index f24445b0..3f7c30c9 100644
--- a/spice.proto
+++ b/spice.proto
@@ -874,7 +874,10 @@ struct CursorHeader {
struct Cursor {
cursor_flags flags;
- CursorHeader header;
+ switch (flags) {
+ case !NONE:
+ CursorHeader header;
+ } u @anon;
uint8 data[] @as_ptr(data_size);
};