Author: Armin Rigo <ar...@tunes.org> Branch: cffi-1.0 Changeset: r1782:e69cf8f75f84 Date: 2015-04-23 09:08 +0200 http://bitbucket.org/cffi/cffi/changeset/e69cf8f75f84/
Log: fixes diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -4086,13 +4086,11 @@ boffsetmax = (boffsetmax + 7) / 8; /* bits -> bytes */ boffsetmax = (boffsetmax + alignment - 1) & ~(alignment-1); if (totalsize < 0) { - totalsize = boffsetmax; - if (totalsize == 0) - totalsize = 1; + totalsize = boffsetmax ? boffsetmax : 1; } else { - if (detect_custom_layout(ct, sflags, boffsetmax, totalsize, - "wrong total size", "", "") < 0) + if (detect_custom_layout(ct, sflags, boffsetmax ? boffsetmax : 1, + totalsize, "wrong total size", "", "") < 0) goto error; if (totalsize < boffsetmax) { PyErr_Format(PyExc_TypeError, diff --git a/cffi/api.py b/cffi/api.py --- a/cffi/api.py +++ b/cffi/api.py @@ -570,7 +570,9 @@ def _set_cdef_types(ffi): struct_unions = [] pending_completion = [] - for name, tp in sorted(ffi._parser._declarations.items()): + lst = ffi._parser._declarations.items() + lst = sorted(lst, key=lambda x: x[0].split(' ', 1)[1]) + for name, tp in lst: kind, basename = name.split(' ', 1) if kind == 'struct' or kind == 'union': if kind == 'struct': diff --git a/new/test_dlopen.py b/new/test_dlopen.py --- a/new/test_dlopen.py +++ b/new/test_dlopen.py @@ -13,6 +13,12 @@ ffi.cdef("union foo_s { int a, b; };") assert ffi.sizeof("union foo_s") == 4 +def test_cdef_struct_union(): + ffi = FFI() + ffi.cdef("union bar_s { int a; }; struct foo_s { int b; };") + assert ffi.sizeof("union bar_s") == 4 + assert ffi.sizeof("struct foo_s") == 4 + def test_math_sin(): py.test.skip("XXX redo!") ffi = FFI() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit