diff options
author | Armin Rigo <arigo@tunes.org> | 2020-05-20 23:29:46 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2020-05-20 23:29:46 +0200 |
commit | bb48fdcc86c5bd2c211fba2ac4cffe8b6efb49e2 (patch) | |
tree | dd4e9101065c0a799cca5c03f31c3c310ef15d9a /cffi/model.py | |
parent | 680aa960da02dfa304c6b889489c05c38de89318 (diff) | |
download | cffi-bb48fdcc86c5bd2c211fba2ac4cffe8b6efb49e2.tar.gz |
#453
Special-case typedefs of arrays with '...' length, so that they can
be used through recompiler.py as if they had a specified length in
most cases.
Diffstat (limited to 'cffi/model.py')
-rw-r--r-- | cffi/model.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cffi/model.py b/cffi/model.py index 5f1b0d2..ad1c176 100644 --- a/cffi/model.py +++ b/cffi/model.py @@ -307,11 +307,14 @@ class ArrayType(BaseType): self.c_name_with_marker = ( self.item.c_name_with_marker.replace('&', brackets)) + def length_is_unknown(self): + return isinstance(self.length, str) + def resolve_length(self, newlength): return ArrayType(self.item, newlength) def build_backend_type(self, ffi, finishlist): - if self.length == '...': + if self.length_is_unknown(): raise CDefError("cannot render the type %r: unknown length" % (self,)) self.item.get_cached_btype(ffi, finishlist) # force the item BType @@ -430,7 +433,7 @@ class StructOrUnion(StructOrUnionOrEnum): fsize = fieldsize[i] ftype = self.fldtypes[i] # - if isinstance(ftype, ArrayType) and ftype.length == '...': + if isinstance(ftype, ArrayType) and ftype.length_is_unknown(): # fix the length to match the total size BItemType = ftype.item.get_cached_btype(ffi, finishlist) nlen, nrest = divmod(fsize, ffi.sizeof(BItemType)) |