[pypy-commit] pypy default: Update to cffi 1.2.1 as released
arigo
noreply at buildbot.pypy.org
Fri Aug 21 15:33:35 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r79116:32db8f8cf274
Date: 2015-08-21 15:33 +0200
http://bitbucket.org/pypy/pypy/changeset/32db8f8cf274/
Log: Update to cffi 1.2.1 as released
diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO
--- a/lib_pypy/cffi.egg-info/PKG-INFO
+++ b/lib_pypy/cffi.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: cffi
-Version: 1.2.0
+Version: 1.2.1
Summary: Foreign Function Interface for Python calling C code.
Home-page: http://cffi.readthedocs.org
Author: Armin Rigo, Maciej Fijalkowski
diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py
--- a/lib_pypy/cffi/__init__.py
+++ b/lib_pypy/cffi/__init__.py
@@ -4,8 +4,8 @@
from .api import FFI, CDefError, FFIError
from .ffiplatform import VerificationError, VerificationMissing
-__version__ = "1.2.0"
-__version_info__ = (1, 2, 0)
+__version__ = "1.2.1"
+__version_info__ = (1, 2, 1)
# 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/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h
--- a/lib_pypy/cffi/_cffi_include.h
+++ b/lib_pypy/cffi/_cffi_include.h
@@ -46,7 +46,7 @@
# endif
#else
# include <stdint.h>
-# if (defined (__SVR4) && defined (__sun)) || defined(_AIX)
+# if (defined (__SVR4) && defined (__sun)) || defined(_AIX) || defined(__hpux)
# include <alloca.h>
# endif
#endif
diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py
--- a/lib_pypy/cffi/cparser.py
+++ b/lib_pypy/cffi/cparser.py
@@ -15,9 +15,11 @@
except ImportError:
lock = None
-_r_comment = re.compile(r"/\*.*?\*/|//.*?$", re.DOTALL | re.MULTILINE)
-_r_define = re.compile(r"^\s*#\s*define\s+([A-Za-z_][A-Za-z_0-9]*)\s+(.*?)$",
- re.MULTILINE)
+_r_comment = re.compile(r"/\*.*?\*/|//([^\n\\]|\\.)*?$",
+ re.DOTALL | re.MULTILINE)
+_r_define = re.compile(r"^\s*#\s*define\s+([A-Za-z_][A-Za-z_0-9]*)"
+ r"\b((?:[^\n\\]|\\.)*?)$",
+ re.DOTALL | re.MULTILINE)
_r_partial_enum = re.compile(r"=\s*\.\.\.\s*[,}]|\.\.\.\s*\}")
_r_enum_dotdotdot = re.compile(r"__dotdotdot\d+__$")
_r_partial_array = re.compile(r"\[\s*\.\.\.\s*\]")
@@ -39,6 +41,7 @@
macros = {}
for match in _r_define.finditer(csource):
macroname, macrovalue = match.groups()
+ macrovalue = macrovalue.replace('\\\n', '').strip()
macros[macroname] = macrovalue
csource = _r_define.sub('', csource)
# Replace "[...]" with "[__dotdotdotarray__]"
@@ -423,13 +426,10 @@
raise api.CDefError(
"%s: a function with only '(...)' as argument"
" is not correct C" % (funcname or 'in expression'))
- elif (len(params) == 1 and
- isinstance(params[0].type, pycparser.c_ast.TypeDecl) and
- isinstance(params[0].type.type, pycparser.c_ast.IdentifierType)
- and list(params[0].type.type.names) == ['void']):
- del params[0]
args = [self._as_func_arg(self._get_type(argdeclnode.type))
for argdeclnode in params]
+ if not ellipsis and args == [model.void_type]:
+ args = []
result = self._get_type(typenode.type)
return model.RawFunctionType(tuple(args), result, ellipsis)
diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py
--- a/lib_pypy/cffi/recompiler.py
+++ b/lib_pypy/cffi/recompiler.py
@@ -4,11 +4,6 @@
VERSION = "0x2601"
-try:
- int_type = (int, long)
-except NameError: # Python 3
- int_type = int
-
class GlobalExpr:
def __init__(self, name, address, type_op, size=0, check_value=0):
diff --git a/lib_pypy/cffi/setuptools_ext.py b/lib_pypy/cffi/setuptools_ext.py
--- a/lib_pypy/cffi/setuptools_ext.py
+++ b/lib_pypy/cffi/setuptools_ext.py
@@ -81,10 +81,16 @@
allsources.extend(kwds.pop('sources', []))
ext = Extension(name=module_name, sources=allsources, **kwds)
- def make_mod(tmpdir):
+ def make_mod(tmpdir, pre_run=None):
c_file = os.path.join(tmpdir, module_name + source_extension)
log.info("generating cffi module %r" % c_file)
mkpath(tmpdir)
+ # a setuptools-only, API-only hook: called with the "ext" and "ffi"
+ # arguments just before we turn the ffi into C code. To use it,
+ # subclass the 'distutils.command.build_ext.build_ext' class and
+ # add a method 'def pre_run(self, ext, ffi)'.
+ if pre_run is not None:
+ pre_run(ext, ffi)
updated = recompiler.make_c_source(ffi, module_name, source, c_file)
if not updated:
log.info("already up-to-date")
@@ -98,7 +104,8 @@
class build_ext_make_mod(base_class):
def run(self):
if ext.sources[0] == '$PLACEHOLDER':
- ext.sources[0] = make_mod(self.build_temp)
+ pre_run = getattr(self, 'pre_run', None)
+ ext.sources[0] = make_mod(self.build_temp, pre_run)
base_class.run(self)
dist.cmdclass['build_ext'] = build_ext_make_mod
# NB. multiple runs here will create multiple 'build_ext_make_mod'
diff --git a/pypy/module/_cffi_backend/__init__.py b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -2,7 +2,7 @@
from pypy.interpreter.mixedmodule import MixedModule
from rpython.rlib import rdynload
-VERSION = "1.2.0"
+VERSION = "1.2.1"
class Module(MixedModule):
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -3427,4 +3427,4 @@
def test_version():
# this test is here mostly for PyPy
- assert __version__ == "1.2.0"
+ assert __version__ == "1.2.1"
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
@@ -160,6 +160,35 @@
assert func.name == 'sin'
assert func.BType == '<func (<double>, <double>), <double>, False>'
+def test_remove_line_continuation_comments():
+ ffi = FFI(backend=FakeBackend())
+ ffi.cdef("""
+ double // blah \\
+ more comments
+ x(void);
+ double // blah\\\\
+ y(void);
+ double // blah\\ \
+ etc
+ z(void);
+ """)
+ m = ffi.dlopen(lib_m)
+ m.x
+ m.y
+ m.z
+
+def test_line_continuation_in_defines():
+ ffi = FFI(backend=FakeBackend())
+ ffi.cdef("""
+ #define ABC\\
+ 42
+ #define BCD \\
+ 43
+ """)
+ m = ffi.dlopen(lib_m)
+ assert m.ABC == 42
+ assert m.BCD == 43
+
def test_define_not_supported_for_now():
ffi = FFI(backend=FakeBackend())
e = py.test.raises(CDefError, ffi.cdef, '#define FOO "blah"')
@@ -238,6 +267,13 @@
ffi = FFI()
ffi.cdef("typedef _Bool bool; void f(bool);")
+def test_void_renamed_as_only_arg():
+ ffi = FFI()
+ ffi.cdef("typedef void void_t1;"
+ "typedef void_t1 void_t;"
+ "typedef int (*func_t)(void_t);")
+ assert ffi.typeof("func_t").args == ()
+
def test_win_common_types():
from cffi.commontypes import COMMON_TYPES, _CACHE
from cffi.commontypes import win_common_types, resolve_common_type
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
@@ -25,6 +25,9 @@
if 1: # test the .cpp mode too
kwds.setdefault('source_extension', '.cpp')
source = 'extern "C" {\n%s\n}' % (source,)
+ else:
+ kwds['extra_compile_args'] = (kwds.get('extra_compile_args', []) +
+ ['-Werror'])
return recompiler._verify(ffi, module_name, source, *args, **kwds)
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_zdist.py b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_zdist.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_zdist.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_zdist.py
@@ -318,15 +318,32 @@
import cffi
ffi = cffi.FFI()
ffi.set_source("pack3.mymod", "/*code would be here*/")
+ ffi._hi_there = 42
""")
with open("setup.py", "w") as f:
- f.write("""if 1:
+ f.write("from __future__ import print_function\n"
+ """if 1:
from setuptools import setup
+ from distutils.command.build_ext import build_ext
+ import os
+
+ class TestBuildExt(build_ext):
+ def pre_run(self, ext, ffi):
+ print('_make_setuptools_api: in pre_run:', end=" ")
+ assert ffi._hi_there == 42
+ assert ext.name == "pack3.mymod"
+ fn = os.path.join(os.path.dirname(self.build_lib),
+ '..', 'see_me')
+ print('creating %r' % (fn,))
+ open(fn, 'w').close()
+
setup(name='example1',
version='0.1',
packages=['pack3'],
package_dir={'': 'src1'},
- cffi_modules=["src1/pack3/_build.py:ffi"])
+ cffi_modules=["src1/pack3/_build.py:ffi"],
+ cmdclass={'build_ext': TestBuildExt},
+ )
""")
@chdir_to_tmp
@@ -335,6 +352,7 @@
self.run(["setup.py", "build"])
self.check_produced_files({'setup.py': None,
'build': '?',
+ 'see_me': None,
'src1': {'pack3': {'__init__.py': None,
'_build.py': None}}})
@@ -344,6 +362,7 @@
self.run(["setup.py", "build_ext", "-i"])
self.check_produced_files({'setup.py': None,
'build': '?',
+ 'see_me': None,
'src1': {'pack3': {'__init__.py': None,
'_build.py': None,
'mymod.SO': None}}})
More information about the pypy-commit
mailing list