[pypy-commit] cffi cmacros: hg merge default
arigo
noreply at buildbot.pypy.org
Thu Jul 30 22:41:25 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cmacros
Changeset: r2234:55774b4c3293
Date: 2015-07-30 16:50 +0200
http://bitbucket.org/cffi/cffi/changeset/55774b4c3293/
Log: hg merge default
diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -15,7 +15,8 @@
except ImportError:
lock = None
-_r_comment = re.compile(r"/\*.*?\*/|//.*?$", re.DOTALL | 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]*)\s+(.*?)$",
re.MULTILINE)
_r_partial_enum = re.compile(r"=\s*\.\.\.\s*[,}]|\.\.\.\s*\}")
@@ -496,13 +497,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/cffi/recompiler.py b/cffi/recompiler.py
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -4,11 +4,6 @@
VERSION = "0x2601"
-try:
- int_type = (int, long)
-except NameError: # Python 3
- int_type = int
-
class Ifdef:
def __init__(self, ifdef, child):
diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
--- a/testing/cffi0/test_parsing.py
+++ b/testing/cffi0/test_parsing.py
@@ -216,6 +216,23 @@
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_define_not_supported_for_now():
ffi = FFI(backend=FakeBackend())
e = py.test.raises(CDefError, ffi.cdef, '#define FOO "blah"')
@@ -294,6 +311,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
More information about the pypy-commit
mailing list