Author: Armin Rigo <ar...@tunes.org> Branch: cffi-1.0 Changeset: r1754:6d8389513bdb Date: 2015-04-18 13:27 +0200 http://bitbucket.org/cffi/cffi/changeset/6d8389513bdb/
Log: fixes diff --git a/cffi/model.py b/cffi/model.py --- a/cffi/model.py +++ b/cffi/model.py @@ -454,6 +454,7 @@ structname = '$%s' % name tp = StructType(structname, None, None, None) tp.force_the_name(name) + tp.origin = "unknown_type" return tp def unknown_ptr_type(name, structname=None): diff --git a/new/recompiler.py b/new/recompiler.py --- a/new/recompiler.py +++ b/new/recompiler.py @@ -150,6 +150,14 @@ prnt('};') prnt() # + # check for a possible internal inconsistency: _cffi_struct_unions + # should have been generated with exactly self._struct_unions + lst = self._lsts["struct_union"] + for tp, i in self._struct_unions.items(): + assert i < len(lst) + assert lst[i].startswith(' { "%s"' % tp.name) + assert len(lst) == len(self._struct_unions) + # # the declaration of '_cffi_type_context' prnt('static const struct _cffi_type_context_s _cffi_type_context = {') prnt(' _cffi_types,') @@ -271,6 +279,10 @@ type_index = self._typesdict[tp] self._lsts["typename"].append( ' { "%s", %d },' % (name, type_index)) + if getattr(tp, "origin", None) == "unknown_type": + self._generate_cpy_struct_ctx(tp, tp.name) + elif isinstance(tp, model.NamedPointerType): + self._generate_cpy_struct_ctx(tp.totype, tp.totype.name) # ---------- # function declarations @@ -539,6 +551,7 @@ self.cffi_types[index] = CffiOp(OP_POINTER, self._typesdict[tp.totype]) _emit_bytecode_ConstPointerType = _emit_bytecode_PointerType + _emit_bytecode_NamedPointerType = _emit_bytecode_PointerType def _emit_bytecode_FunctionPtrType(self, tp, index): raw = tp.as_raw_function() diff --git a/new/test_recompiler.py b/new/test_recompiler.py --- a/new/test_recompiler.py +++ b/new/test_recompiler.py @@ -118,6 +118,16 @@ lib = verify(ffi, 'test_verify_typedef', 'typedef int **foo_t;') assert ffi.sizeof("foo_t") == ffi.sizeof("void *") +def test_verify_typedef_dotdotdot(): + ffi = FFI() + ffi.cdef("typedef ... foo_t;") + verify(ffi, 'test_verify_typedef_dotdotdot', 'typedef int **foo_t;') + +def test_verify_typedef_star_dotdotdot(): + ffi = FFI() + ffi.cdef("typedef ... *foo_t;") + verify(ffi, 'test_verify_typedef_star_dotdotdot', 'typedef int **foo_t;') + def test_global_var_int(): ffi = FFI() ffi.cdef("int a, b, c;") _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit