diff options
author | Armin Rigo <arigo@tunes.org> | 2020-12-06 20:22:33 +0100 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2020-12-06 20:22:33 +0100 |
commit | faf9d0105c905753cb69952f028e507f8353a287 (patch) | |
tree | 27b8995843d79c4a202e3275e26563d32d36f0b7 /lib_pypy/cffi | |
parent | move "thread from "requires" to "suggested" for sandbox, compatibility with p... (diff) | |
download | pypy-faf9d0105c905753cb69952f028e507f8353a287.tar.gz pypy-faf9d0105c905753cb69952f028e507f8353a287.tar.bz2 pypy-faf9d0105c905753cb69952f028e507f8353a287.zip |
update to cffi/023e2f33ee07
Diffstat (limited to 'lib_pypy/cffi')
-rw-r--r-- | lib_pypy/cffi/__init__.py | 4 | ||||
-rw-r--r-- | lib_pypy/cffi/_embedding.h | 2 | ||||
-rw-r--r-- | lib_pypy/cffi/recompiler.py | 18 |
3 files changed, 17 insertions, 7 deletions
diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py index 264afa162a..644dea74c1 100644 --- a/lib_pypy/cffi/__init__.py +++ b/lib_pypy/cffi/__init__.py @@ -5,8 +5,8 @@ from .api import FFI from .error import CDefError, FFIError, VerificationError, VerificationMissing from .error import PkgConfigError -__version__ = "1.14.3" -__version_info__ = (1, 14, 3) +__version__ = "1.14.4" +__version_info__ = (1, 14, 4) # The verifier module file names are based on the CRC32 of a string that # contains the following version number. It may be older than __version__ diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h index fdce222862..cae179acb1 100644 --- a/lib_pypy/cffi/_embedding.h +++ b/lib_pypy/cffi/_embedding.h @@ -224,7 +224,7 @@ static int _cffi_initialize_python(void) if (f != NULL && f != Py_None) { PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME - "\ncompiled with cffi version: 1.14.3" + "\ncompiled with cffi version: 1.14.4" "\n_cffi_backend module: ", f); modules = PyImport_GetModuleDict(); mod = PyDict_GetItemString(modules, "_cffi_backend"); diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py index 1aeae5b92a..86b37d7ffc 100644 --- a/lib_pypy/cffi/recompiler.py +++ b/lib_pypy/cffi/recompiler.py @@ -193,6 +193,17 @@ class Recompiler: assert isinstance(op, CffiOp) self.cffi_types = tuple(self.cffi_types) # don't change any more + def _enum_fields(self, tp): + # When producing C, expand all anonymous struct/union fields. + # That's necessary to have C code checking the offsets of the + # individual fields contained in them. When producing Python, + # don't do it and instead write it like it is, with the + # corresponding fields having an empty name. Empty names are + # recognized at runtime when we import the generated Python + # file. + expand_anonymous_struct_union = not self.target_is_python + return tp.enumfields(expand_anonymous_struct_union) + def _do_collect_type(self, tp): if not isinstance(tp, model.BaseTypeByIdentity): if isinstance(tp, tuple): @@ -206,7 +217,7 @@ class Recompiler: elif isinstance(tp, model.StructOrUnion): if tp.fldtypes is not None and ( tp not in self.ffi._parser._included_declarations): - for name1, tp1, _, _ in tp.enumfields(): + for name1, tp1, _, _ in self._enum_fields(tp): self._do_collect_type(self._field_type(tp, name1, tp1)) else: for _, x in tp._get_items(): @@ -864,7 +875,7 @@ class Recompiler: prnt('{') prnt(' /* only to generate compile-time warnings or errors */') prnt(' (void)p;') - for fname, ftype, fbitsize, fqual in tp.enumfields(): + for fname, ftype, fbitsize, fqual in self._enum_fields(tp): try: if ftype.is_integer_type() or fbitsize >= 0: # accept all integers, but complain on float or double @@ -920,8 +931,7 @@ class Recompiler: flags = '|'.join(flags) or '0' c_fields = [] if reason_for_not_expanding is None: - expand_anonymous_struct_union = not self.target_is_python - enumfields = list(tp.enumfields(expand_anonymous_struct_union)) + enumfields = list(self._enum_fields(tp)) for fldname, fldtype, fbitsize, fqual in enumfields: fldtype = self._field_type(tp, fldname, fldtype) self._check_not_opaque(fldtype, |