Author: Ronan Lamy <[email protected]>
Branch: rffi-parser-2
Changeset: r89219:65ef8cf5625f
Date: 2016-12-23 18:05 +0100
http://bitbucket.org/pypy/pypy/changeset/65ef8cf5625f/

Log:    Improve test_include()

diff --git a/pypy/module/cpyext/test/test_cparser.py 
b/pypy/module/cpyext/test/test_cparser.py
--- a/pypy/module/cpyext/test/test_cparser.py
+++ b/pypy/module/cpyext/test/test_cparser.py
@@ -46,7 +46,7 @@
     assert 'PyFloatObject' in hdr.definitions
     assert 'PyObject_HEAD' in hdr.macros
 
-def test_include():
+def test_include(tmpdir):
     cdef1 = """
     typedef ssize_t Py_ssize_t;
 
@@ -58,7 +58,8 @@
         char *name;
     } Type;
     """
-    hdr1 = parse_source(cdef1)
+    base_name = tmpdir / 'base.h'
+    base_name.write(cdef1)
     cdef2 = """
     typedef struct {
         PyObject_HEAD
@@ -66,6 +67,16 @@
         Type *type;
     } Object;
     """
-    hdr2 = parse_source(cdef2, includes=[hdr1])
-    assert 'Object' in hdr2.definitions
+    (tmpdir / 'object.h').write(cdef2)
+    eci = ExternalCompilationInfo(
+        include_dirs=[str(tmpdir)],
+        includes=['sys/types.h', 'base.h', 'object.h'])
+    hdr1 = parse_source(cdef1, eci=eci)
+    hdr1.configure_types()
+    Type = hdr1.definitions['Type'].OF
+    assert isinstance(Type, lltype.Struct)
+    hdr2 = parse_source(cdef2, includes=[hdr1], eci=eci)
+    hdr2.configure_types()
     assert 'Type' not in hdr2.definitions
+    Object = hdr2.definitions['Object'].OF
+    assert Object.c_type.TO is Type
diff --git a/pypy/module/cpyext/typeobjectdefs.py 
b/pypy/module/cpyext/typeobjectdefs.py
--- a/pypy/module/cpyext/typeobjectdefs.py
+++ b/pypy/module/cpyext/typeobjectdefs.py
@@ -31,6 +31,7 @@
 initproc = P(FT([PyO, PyO, PyO], rffi.INT_real))
 newfunc = P(FT([PyTypeObjectPtr, PyO, PyO], PyO))
 allocfunc = P(FT([PyTypeObjectPtr, Py_ssize_t], PyO))
+
 unaryfunc = P(FT([PyO], PyO))
 binaryfunc = P(FT([PyO, PyO], PyO))
 ternaryfunc = P(FT([PyO, PyO, PyO], PyO))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to