diff options
author | 2017-03-15 21:24:39 +0100 | |
---|---|---|
committer | 2017-03-15 21:24:39 +0100 | |
commit | 061b11914250a257b883a5078f42790331b13cab (patch) | |
tree | ea8c0c9c6805d1c5bf5b9d18b29eb3ed14e8cc9d | |
parent | a few more details (diff) | |
download | pypy-061b11914250a257b883a5078f42790331b13cab.tar.gz pypy-061b11914250a257b883a5078f42790331b13cab.tar.bz2 pypy-061b11914250a257b883a5078f42790331b13cab.zip |
import cffi/663852865a03
-rw-r--r-- | lib_pypy/cffi/cparser.py | 10 | ||||
-rw-r--r-- | pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py index 3d5caed8d7..0c8ef3ffcb 100644 --- a/lib_pypy/cffi/cparser.py +++ b/lib_pypy/cffi/cparser.py @@ -803,6 +803,16 @@ class Parser(object): "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/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py index 7198d923af..caceb3206d 100644 --- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py +++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py @@ -387,13 +387,14 @@ def test_const_pointer_to_pointer(): 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() |