Commit 41ab2fa7 authored by Armin Rigo's avatar Armin Rigo
Browse files

Issue #207: fix for anonymous enums with ffi.include()

parent f6fcbe96b598
......@@ -633,6 +633,8 @@ class Parser(object):
def include(self, other):
for name, tp in other._declarations.items():
if name.startswith('anonymous $enum_$'):
continue # fix for test_anonymous_enum_include
kind = name.split(' ', 1)[0]
if kind in ('struct', 'union', 'enum', 'anonymous'):
self._declare(name, tp, included=True)
......
......@@ -1774,3 +1774,14 @@ class BackendTests:
def test_ffi_self_include(self):
ffi = FFI(backend=self.Backend())
py.test.raises(ValueError, ffi.include, ffi)
def test_anonymous_enum_include(self):
ffi1 = FFI()
ffi1.cdef("enum { EE1 };")
ffi = FFI()
ffi.include(ffi1)
ffi.cdef("enum { EE2, EE3 };")
lib = ffi.dlopen(None)
assert lib.EE1 == 0
assert lib.EE2 == 0
assert lib.EE3 == 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment