def ctypes_to_C(ctype):
"""Map ctypes types to C types."""
if issubclass(ctype, ctypes.Structure):
return 'struct %s' % ctype.__name__
elif issubclass(ctype, ctypes.Union):
return 'union %s' % ctype.__name__
elif ctype.__name__.startswith('c_'):
# FIXME: Is there a better way of extracting the C typename ?
# Here, we're following the ctypes convention that each basic type has
# the format c_X_p, where X is the C typename, for instance `int` or `float`.
return ctype.__name__[2:-2]
else:
raise TypeError('Unrecognised %s during converstion to C type' % str(ctype))
评论列表
文章目录