diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-07-05 12:03:34 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2010-07-05 12:03:34 +0200 |
commit | 4a60f1822a356e4e1e2d7ecd2d18f4e3fce48f85 (patch) | |
tree | 984567a8ef042ae63dbe36a9c4a386e850afe33d /python_modules/ptypes.py | |
parent | 3764a3647224a5e9dde021828d3b17fe5fc9fdeb (diff) | |
download | spice-4a60f1822a356e4e1e2d7ecd2d18f4e3fce48f85.tar.gz spice-4a60f1822a356e4e1e2d7ecd2d18f4e3fce48f85.tar.xz spice-4a60f1822a356e4e1e2d7ecd2d18f4e3fce48f85.zip |
marshaller: Add generic way to handle propagating attributes
Also switches @ptr_array to use this
Diffstat (limited to 'python_modules/ptypes.py')
-rw-r--r-- | python_modules/ptypes.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py index 055034eb..cc74b72c 100644 --- a/python_modules/ptypes.py +++ b/python_modules/ptypes.py @@ -55,6 +55,13 @@ class FixedSize: s = s + " + ((minor >= %d)?%d:0)" % (i, self.vals[i]) return s +# Some attribute are propagated from member to the type as they really +# are part of the type definition, rather than the member. This applies +# 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"] + class Type: def __init__(self): self.attributes = {} @@ -353,7 +360,6 @@ class ArrayType(Type): self.element_type = element_type self.size = size - self.ptr_array = False def __str__(self): if self.size == None: @@ -416,7 +422,7 @@ class ArrayType(Type): raise Exception, "Pointer names in arrays not supported" def is_extra_size(self): - return self.ptr_array + return self.has_attr("ptr_array") def contains_extra_size(self): return self.element_type.contains_extra_size() @@ -516,8 +522,9 @@ class Member(Containee): self.member_type.register() if self.has_attr("ptr32") and self.member_type.is_pointer(): self.member_type.set_ptr_size(4) - if self.has_attr("ptr_array") and self.member_type.is_array(): - self.member_type.ptr_array = True + for i in propagated_attributes: + if self.has_attr(i): + self.member_type.attributes[i] = self.attributes[i] return self def is_primitive(self): |