[pypy-commit] cffi release-1.10: hg merge default
arigo
pypy.commits at gmail.com
Wed Mar 15 16:25:17 EDT 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: release-1.10
Changeset: r2914:00667b1b0ab3
Date: 2017-03-15 21:25 +0100
http://bitbucket.org/cffi/cffi/changeset/00667b1b0ab3/
Log: hg merge default
diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -803,6 +803,16 @@
"the actual array length in this context"
% exprnode.coord.line)
#
+ if (isinstance(exprnode, pycparser.c_ast.BinaryOp) and
+ exprnode.op == '+'):
+ return (self._parse_constant(exprnode.left) +
+ self._parse_constant(exprnode.right))
+ #
+ if (isinstance(exprnode, pycparser.c_ast.BinaryOp) and
+ exprnode.op == '-'):
+ return (self._parse_constant(exprnode.left) -
+ self._parse_constant(exprnode.right))
+ #
raise FFIError(":%d: unsupported expression: expected a "
"simple numeric constant" % exprnode.coord.line)
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
@@ -386,13 +386,14 @@
def test_enum():
ffi = FFI()
ffi.cdef("""
- enum Enum { POS = +1, TWO = 2, NIL = 0, NEG = -1};
+ enum Enum { POS = +1, TWO = 2, NIL = 0, NEG = -1, OP = (POS+TWO)-1};
""")
C = ffi.dlopen(None)
assert C.POS == 1
assert C.TWO == 2
assert C.NIL == 0
assert C.NEG == -1
+ assert C.OP == 2
def test_stdcall():
ffi = FFI()
More information about the pypy-commit
mailing list