summaryrefslogtreecommitdiffstats
path: root/python_modules
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-07-05 12:13:45 +0200
committerAlexander Larsson <alexl@redhat.com>2010-07-05 12:13:45 +0200
commitd161994f46af7c77e428f11fea84eb34fc097449 (patch)
tree5c709d17e9186fe93e336f6c4e95c45ac4ccffd2 /python_modules
parentd7164a0669b0f8c6531b1728f4fbda32647942ba (diff)
downloadspice-d161994f46af7c77e428f11fea84eb34fc097449.tar.gz
spice-d161994f46af7c77e428f11fea84eb34fc097449.tar.xz
spice-d161994f46af7c77e428f11fea84eb34fc097449.zip
marshaller: Make @nonnull a propagated attribute
This cleans up some stuff
Diffstat (limited to 'python_modules')
-rw-r--r--python_modules/demarshal.py5
-rw-r--r--python_modules/marshal.py2
-rw-r--r--python_modules/ptypes.py2
3 files changed, 3 insertions, 6 deletions
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 5a8f8ffa..57095675 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -82,7 +82,6 @@ class ItemInfo:
self.prefix = prefix
self.subprefix = prefix
self.position = position
- self.non_null = False
self.member = None
def nw_size(self):
@@ -103,7 +102,6 @@ class MemberItemInfo(ItemInfo):
self.type = member.member_type
self.prefix = member.name
self.subprefix = member.name
- self.non_null = member.has_attr("nonnull")
self.position = "(%s + %s)" % (start, container.get_nw_offset(member, "", "__nw_size"))
self.member = member
@@ -123,7 +121,6 @@ def write_validate_switch_member(writer, container, switch_member, scope, parent
with writer.if_block(check, not first, False) as if_scope:
item.type = c.member.member_type
item.subprefix = item.prefix + "_" + m.name
- item.non_null = c.member.has_attr("nonnull")
sub_want_extra_size = want_extra_size
if sub_want_extra_size and not m.contains_extra_size() and not m.is_extra_size():
writer.assign(item.extra_size(), 0)
@@ -192,7 +189,7 @@ def write_validate_pointer_item(writer, container, item, scope, parent_scope, st
target_type = item.type.target_type
v = write_read_primitive_item(writer, item, scope)
- if item.non_null:
+ if item.type.has_attr("nonnull"):
writer.error_check("%s == 0" % v)
# pointer target is struct, or array of primitives
diff --git a/python_modules/marshal.py b/python_modules/marshal.py
index f151d948..df0c3b33 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -235,7 +235,7 @@ def write_pointer_marshaller(writer, member, src):
submarshaller = "spice_marshaller_get_ptr_submarshaller(m, %d)" % (1 if member.get_fixed_nw_size() == 8 else 0)
if member.has_attr("marshall"):
writer.assign("m2", submarshaller)
- if member.has_attr("nonnull"):
+ if t.has_attr("nonnull"):
writer.statement("%s(m2, %s)" % (ptr_func, src.get_ref(member.name)))
else:
with writer.if_block("%s != NULL" % src.get_ref(member.name)) as block:
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 2c0dd880..31ae79d7 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -60,7 +60,7 @@ class FixedSize:
# only to attributes that affect pointer or array attributes, as these
# are member local types, unlike e.g. a Struct that may be used by
# other members
-propagated_attributes=["ptr_array", "c_ptr"]
+propagated_attributes=["ptr_array", "c_ptr", "nonnull"]
class Type:
def __init__(self):