test_new_ffi_1.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:SwiftKitten 作者: johncsnyder 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号