def test_introspect_included_type(self): ffi1 = FFI() ffi2 = FFI() ffi1.cdef("typedef signed char schar_t; struct sint_t { int x; };") ffi2.include(ffi1) assert ffi1.list_types() == ffi2.list_types() == (['schar_t' ], ['sint_t'], [])
def test_introspect_included_type(self): ffi1 = FFI() ffi2 = FFI() ffi1.cdef("typedef signed char schar_t; struct sint_t { int x; };") ffi2.include(ffi1) assert ffi1.list_types() == ffi2.list_types() == ( ['schar_t'], ['sint_t'], [])
def test_introspect_typedef(self): ffi = FFI() ffi.cdef("typedef int foo_t;") assert ffi.list_types() == (['foo_t'], [], []) assert ffi.typeof('foo_t').kind == 'primitive' assert ffi.typeof('foo_t').cname == 'int' # ffi.cdef("typedef signed char a_t, c_t, g_t, b_t;") assert ffi.list_types() == (['a_t', 'b_t', 'c_t', 'foo_t', 'g_t'], [], [])
def test_introspect_typedef(self): ffi = FFI() ffi.cdef("typedef int foo_t;") assert ffi.list_types() == (['foo_t'], [], []) assert ffi.typeof('foo_t').kind == 'primitive' assert ffi.typeof('foo_t').cname == 'int' # ffi.cdef("typedef signed char a_t, c_t, g_t, b_t;") assert ffi.list_types() == (['a_t', 'b_t', 'c_t', 'foo_t', 'g_t'], [], [])
def test_introspect_order(self): ffi = FFI() ffi.cdef("union aaa { int a; }; typedef struct ccc { int a; } b;") ffi.cdef("union g { int a; }; typedef struct cc { int a; } bbb;") ffi.cdef("union aa { int a; }; typedef struct a { int a; } bb;") assert ffi.list_types() == (['b', 'bb', 'bbb'], ['a', 'cc', 'ccc'], ['aa', 'aaa', 'g'])
def test_introspect_order(self): ffi = FFI() ffi.cdef("union CFFIaaa { int a; }; typedef struct CFFIccc { int a; } CFFIb;") ffi.cdef("union CFFIg { int a; }; typedef struct CFFIcc { int a; } CFFIbbb;") ffi.cdef("union CFFIaa { int a; }; typedef struct CFFIa { int a; } CFFIbb;") assert ffi.list_types() == (['CFFIb', 'CFFIbb', 'CFFIbbb'], ['CFFIa', 'CFFIcc', 'CFFIccc'], ['CFFIaa', 'CFFIaaa', 'CFFIg'])
def test_introspect_order(self): ffi = FFI() ffi.cdef("union CFFIaaa { int a; }; typedef struct CFFIccc { int a; } CFFIb;") ffi.cdef("union CFFIg { int a; }; typedef struct CFFIcc { int a; } CFFIbbb;") ffi.cdef("union CFFIaa { int a; }; typedef struct CFFIa { int a; } CFFIbb;") assert ffi.list_types() == (['CFFIb', 'CFFIbb', 'CFFIbbb'], ['CFFIa', 'CFFIcc', 'CFFIccc'], ['CFFIaa', 'CFFIaaa', 'CFFIg'])
def test_introspect_struct_and_typedef(self): ffi = FFI() ffi.cdef("typedef struct { int a; } foo_t;") assert ffi.list_types() == (['foo_t'], [], []) assert ffi.typeof('foo_t').kind == 'struct' assert ffi.typeof('foo_t').cname == 'foo_t'
def test_introspect_union(self): ffi = FFI() ffi.cdef("union foo_s { int a; };") assert ffi.list_types() == ([], [], ['foo_s']) assert ffi.typeof('union foo_s').kind == 'union' assert ffi.typeof('union foo_s').cname == 'union foo_s'
def test_introspect_struct(self): ffi = FFI() ffi.cdef("struct foo_s { int a; };") assert ffi.list_types() == ([], ['foo_s'], []) assert ffi.typeof('struct foo_s').kind == 'struct' assert ffi.typeof('struct foo_s').cname == 'struct foo_s'
def test_introspect_struct_and_typedef(self): ffi = FFI() ffi.cdef("typedef struct { int a; } foo_t;") assert ffi.list_types() == (['foo_t'], [], []) assert ffi.typeof('foo_t').kind == 'struct' assert ffi.typeof('foo_t').cname == 'foo_t'
def test_introspect_union(self): ffi = FFI() ffi.cdef("union foo_s { int a; };") assert ffi.list_types() == ([], [], ['foo_s']) assert ffi.typeof('union foo_s').kind == 'union' assert ffi.typeof('union foo_s').cname == 'union foo_s'
def test_introspect_struct(self): ffi = FFI() ffi.cdef("struct foo_s { int a; };") assert ffi.list_types() == ([], ['foo_s'], []) assert ffi.typeof('struct foo_s').kind == 'struct' assert ffi.typeof('struct foo_s').cname == 'struct foo_s'
void ImDrawList_ChannelsSetCurrent(ImDrawList* list, int channel_index); // Advanced void ImDrawList_AddCallback(ImDrawList* list, ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles. void ImDrawList_AddDrawCmd(ImDrawList* list); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible // Internal helpers void ImDrawList_PrimReserve(ImDrawList* list, int idx_count, int vtx_count); void ImDrawList_PrimRect(ImDrawList* list, const struct ImVec2 a, const struct ImVec2 b, ImU32 col); void ImDrawList_PrimRectUV(ImDrawList* list, const struct ImVec2 a, const struct ImVec2 b, const struct ImVec2 uv_a, const struct ImVec2 uv_b, ImU32 col); void ImDrawList_PrimQuadUV(ImDrawList* list,const struct ImVec2 a, const struct ImVec2 b, const struct ImVec2 c, const struct ImVec2 d, const struct ImVec2 uv_a, const struct ImVec2 uv_b, const struct ImVec2 uv_c, const struct ImVec2 uv_d, ImU32 col); void ImDrawList_PrimVtx(ImDrawList* list, const struct ImVec2 pos, const struct ImVec2 uv, ImU32 col); void ImDrawList_PrimWriteVtx(ImDrawList* list, const struct ImVec2 pos, const struct ImVec2 uv, ImU32 col); void ImDrawList_PrimWriteIdx(ImDrawList* list, ImDrawIdx idx); void ImDrawList_UpdateClipRect(ImDrawList* list); void ImDrawList_UpdateTextureID(ImDrawList* list); """) if platform.system() == "Windows": DLL_FNAME = "cimguid.dll" elif platform.system() == "Darwin": DLL_FNAME = "libcimgui.dylib" DLL_FPATH = os.path.join(THIS_DIR, "_dlls", DLL_FNAME) C = ffi.dlopen(DLL_FPATH) print(ffi.list_types()) __all__ = ['ffi', 'C']
// Advanced void ImDrawList_AddCallback(ImDrawList* list, ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles. void ImDrawList_AddDrawCmd(ImDrawList* list); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible // Internal helpers void ImDrawList_PrimReserve(ImDrawList* list, int idx_count, int vtx_count); void ImDrawList_PrimRect(ImDrawList* list, const struct ImVec2 a, const struct ImVec2 b, ImU32 col); void ImDrawList_PrimRectUV(ImDrawList* list, const struct ImVec2 a, const struct ImVec2 b, const struct ImVec2 uv_a, const struct ImVec2 uv_b, ImU32 col); void ImDrawList_PrimQuadUV(ImDrawList* list,const struct ImVec2 a, const struct ImVec2 b, const struct ImVec2 c, const struct ImVec2 d, const struct ImVec2 uv_a, const struct ImVec2 uv_b, const struct ImVec2 uv_c, const struct ImVec2 uv_d, ImU32 col); void ImDrawList_PrimVtx(ImDrawList* list, const struct ImVec2 pos, const struct ImVec2 uv, ImU32 col); void ImDrawList_PrimWriteVtx(ImDrawList* list, const struct ImVec2 pos, const struct ImVec2 uv, ImU32 col); void ImDrawList_PrimWriteIdx(ImDrawList* list, ImDrawIdx idx); void ImDrawList_UpdateClipRect(ImDrawList* list); void ImDrawList_UpdateTextureID(ImDrawList* list); """) if platform.system() == "Windows": DLL_FNAME = "cimguid.dll" elif platform.system() == "Darwin": DLL_FNAME = "libcimgui.dylib" DLL_FPATH = os.path.join(THIS_DIR, "_dlls", DLL_FNAME) C = ffi.dlopen(DLL_FPATH) print(ffi.list_types()) __all__ = ['ffi', 'C']