def test_include_struct_union_enum_typedef(self):
ffi1, CCODE = construction_params
ffi2 = cffi.FFI()
ffi2.include(ffi1)
outputfilename = recompile(ffi2,
"test_include_struct_union_enum_typedef",
CCODE, tmpdir=str(udir))
module = imp.load_dynamic("test_include_struct_union_enum_typedef",
outputfilename)
ffi2 = module.ffi
#
p = ffi2.new("struct nonpacked *", [b'A', -43141])
assert p.a == b'A'
assert p.b == -43141
#
p = ffi.new("union simple_u *", [-52525])
assert p.a == -52525
#
p = ffi.cast("enum foq", 2)
assert ffi.string(p) == "cffiCC0"
assert ffi2.sizeof("char[cffiCC0]") == 2
#
p = ffi.new("anon_foo_t *", [-52526])
assert p.a == -52526
p = ffi.new("named_foo_p", [-52527])
assert p.a == -52527
评论列表
文章目录