summaryrefslogtreecommitdiff
path: root/cffi/model.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2018-01-31 21:39:19 +0100
committerArmin Rigo <arigo@tunes.org>2018-01-31 21:39:19 +0100
commit0c20cb6f04a8bbae352bf71e4cab149da77f5918 (patch)
tree6569799e9f46315c0479d95cc6161bc1f7fbf1be /cffi/model.py
parent6d08968ac72990cefcb33c9efb58e68f320c6424 (diff)
downloadcffi-0c20cb6f04a8bbae352bf71e4cab149da77f5918.tar.gz
Issue #357: fix the out-of-line ABI mode when we see structs
containing anonymous unions or vice-versa
Diffstat (limited to 'cffi/model.py')
-rw-r--r--cffi/model.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/cffi/model.py b/cffi/model.py
index fb30f7d..5d1139d 100644
--- a/cffi/model.py
+++ b/cffi/model.py
@@ -352,21 +352,20 @@ class StructOrUnion(StructOrUnionOrEnum):
self.fldquals = fldquals
self.build_c_name_with_marker()
- def has_anonymous_struct_fields(self):
- if self.fldtypes is None:
- return False
- for name, type in zip(self.fldnames, self.fldtypes):
- if name == '' and isinstance(type, StructOrUnion):
- return True
- return False
+ def anonymous_struct_fields(self):
+ if self.fldtypes is not None:
+ for name, type in zip(self.fldnames, self.fldtypes):
+ if name == '' and isinstance(type, StructOrUnion):
+ yield type
- def enumfields(self):
+ def enumfields(self, expand_anonymous_struct_union=True):
fldquals = self.fldquals
if fldquals is None:
fldquals = (0,) * len(self.fldnames)
for name, type, bitsize, quals in zip(self.fldnames, self.fldtypes,
self.fldbitsize, fldquals):
- if name == '' and isinstance(type, StructOrUnion):
+ if (name == '' and isinstance(type, StructOrUnion)
+ and expand_anonymous_struct_union):
# nested anonymous struct/union
for result in type.enumfields():
yield result