[C++-sig] [Py++] ctypes generator ignores bit fields

Nikolaus Rath Nikolaus at rath.org
Sat Dec 26 01:26:28 CET 2009


The ctypes code generator translates the struct

struct fuse_file_info {
	int flags;
	unsigned long fh_old;
	int writepage;
	unsigned int direct_io : 1;
	unsigned int keep_cache : 1;
	unsigned int flush : 1;
	unsigned int padding : 29;
	uint64_t fh;
	uint64_t lock_owner;


fuse_file_info._fields_ = [ #class fuse_file_info
    ("flags", ctypes.c_int),
    ("fh_old", ctypes.c_ulong),
    ("writepage", ctypes.c_int),
    ("direct_io", ctypes.c_uint),
    ("keep_cache", ctypes.c_uint),
    ("flush", ctypes.c_uint),
    ("padding", ctypes.c_uint),
    ("fh", ctypes.c_ulonglong),
    ("lock_owner", ctypes.c_ulonglong),

but this is wrong, the correct translation is:

fuse_file_info._fields_ = [
        ('flags', ctypes.c_int),
        ('fh_old', ctypes.c_ulong),
        ('writepage', ctypes.c_int),
        ('direct_io', ctypes.c_uint, 1),
        ('keep_cache', ctypes.c_uint, 1),
        ('flush', ctypes.c_uint, 1),
        ('padding', ctypes.c_uint, 29),
        ('fh', ctypes.c_uint64),
        ('lock_owner', ctypes.c_uint64)]



 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

More information about the Cplusplus-sig mailing list