[pypy-commit] cffi sirtom67/float_complex: merge default in again.

sirtom67 pypy.commits at gmail.com
Mon Mar 27 09:33:19 EDT 2017


Author: Tom Krauss <thomas.p.krauss at gmail.com>
Branch: sirtom67/float_complex
Changeset: r2920:8e884c0520fe
Date: 2017-03-19 18:33 -0500
http://bitbucket.org/cffi/cffi/changeset/8e884c0520fe/

Log:	merge default in again.

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/backend_tests.py b/testing/cffi0/backend_tests.py
--- a/testing/cffi0/backend_tests.py
+++ b/testing/cffi0/backend_tests.py
@@ -1230,7 +1230,8 @@
     def test_ffi_buffer_comparisons(self):
         ffi = FFI(backend=self.Backend())
         ba = bytearray(range(100, 110))
-        assert ba == memoryview(ba)    # justification for the following
+        if sys.version_info >= (2, 7):
+            assert ba == memoryview(ba)    # justification for the following
         a = ffi.new("uint8_t[]", list(ba))
         c = ffi.new("uint8_t[]", [99] + list(ba))
         try:
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()
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
--- a/testing/cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -2063,7 +2063,7 @@
             struct foo s = { 40, 200 };
             return s;
         }
-        struct foo g(int a, ...) { }
+        struct foo g(int a, ...) { return f(); }
     """)
     assert lib.f().x == 200
     e = py.test.raises(NotImplementedError, lib.g, 0)
@@ -2092,7 +2092,7 @@
             s.b = 200;
             return s;
         }
-        struct foo g(int a, ...) { }
+        struct foo g(int a, ...) { return f(); }
     """)
     assert lib.f().b == 200
     e = py.test.raises(NotImplementedError, lib.g, 0)
@@ -2118,7 +2118,7 @@
             struct foo s = { 11 };
             return s;
         }
-        struct foo g(int a, ...) { }
+        struct foo g(int a, ...) { return f(); }
     """)
     assert lib.f().x == 11
     e = py.test.raises(NotImplementedError, lib.g, 0)
@@ -2130,6 +2130,8 @@
         "set_source() and not taking a final '...' argument)")
 
 def test_call_with_zero_length_field():
+    if sys.platform == 'win32':
+        py.test.skip("zero-length field not supported by MSVC")
     ffi = FFI()
     ffi.cdef("""
         struct foo { int a; int x[0]; };
@@ -2142,7 +2144,7 @@
             struct foo s = { 42 };
             return s;
         }
-        struct foo g(int a, ...) { }
+        struct foo g(int a, ...) { return f(); }
     """)
     assert lib.f().a == 42
     e = py.test.raises(NotImplementedError, lib.g, 0)
@@ -2166,7 +2168,7 @@
             union foo s = { 42 };
             return s;
         }
-        union foo g(int a, ...) { }
+        union foo g(int a, ...) { return f(); }
     """)
     assert lib.f().a == 42
     e = py.test.raises(NotImplementedError, lib.g, 0)


More information about the pypy-commit mailing list