0

我想要一个可以将 ctypes 对象转换为 cffi 对象的通用函数。它可能如下所示

def ctypestocffi(ctypes_obj):
    return ffi.cast(get_type_definition(ctypes_obj), ctypes_obj)

get_type_definition(ctypes.c_int)=='int'
get_type_definition(ctypes.c_int*10)=='int[10]' #or 'int[]'

我认为 ctypes 本身应该具有这种功能,但据我所知它没有。该函数需要与结构、指针和任何通用 c 类型对象一起工作。

有谁知道我正在寻找的功能?或者有什么理由可以解释为什么这种功能没有在 ctypes 中实现?

4

0 回答 0