[pypy-commit] cffi cffi-1.0: Test and fix
arigo
noreply at buildbot.pypy.org
Wed Apr 29 20:22:46 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1880:e5f48577bca9
Date: 2015-04-29 20:23 +0200
http://bitbucket.org/cffi/cffi/changeset/e5f48577bca9/
Log: Test and fix
diff --git a/_cffi1/test_recompiler.py b/_cffi1/test_recompiler.py
--- a/_cffi1/test_recompiler.py
+++ b/_cffi1/test_recompiler.py
@@ -568,11 +568,31 @@
"typedef struct _mystruct_s mystruct_t;")
ffi = FFI()
ffi.include(ffi1)
- ffi.cdef("mystruct_t *ff6(void);")
+ ffi.cdef("mystruct_t *ff6(void); int ff6b(mystruct_t *);")
lib = verify(ffi, "test_include_6",
"typedef struct _mystruct_s mystruct_t; //usually from a #include\n"
"struct _mystruct_s { int x; };\n"
"static mystruct_t result_struct = { 42 };\n"
- "mystruct_t *ff6(void) { return &result_struct; }")
+ "mystruct_t *ff6(void) { return &result_struct; }\n"
+ "int ff6b(mystruct_t *p) { return p->x; }")
p = lib.ff6()
assert ffi.cast("int *", p)[0] == 42
+ assert lib.ff6b(p) == 42
+
+def test_include_7():
+ ffi1 = FFI()
+ ffi1.cdef("typedef ... mystruct_t;\n"
+ "int ff7b(mystruct_t *);")
+ verify(ffi1, "test_include_7_parent",
+ "typedef struct { int x; } mystruct_t;\n"
+ "int ff7b(mystruct_t *p) { return p->x; }")
+ ffi = FFI()
+ ffi.include(ffi1)
+ ffi.cdef("mystruct_t *ff7(void);")
+ lib = verify(ffi, "test_include_7",
+ "typedef struct { int x; } mystruct_t; //usually from a #include\n"
+ "static mystruct_t result_struct = { 42 };"
+ "mystruct_t *ff7(void) { return &result_struct; }")
+ p = lib.ff7()
+ assert ffi.cast("int *", p)[0] == 42
+ assert lib.ff7b(p) == 42
diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -611,6 +611,6 @@
if kind in ('struct', 'union', 'enum', 'anonymous'):
self._declare(name, tp, included=True)
elif kind == 'typedef':
- self._declare(name, tp)
+ self._declare(name, tp, included=True)
for k, v in other._int_constants.items():
self._add_constants(k, v)
More information about the pypy-commit
mailing list