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

Roman Yakovenko roman.yakovenko at gmail.com
Sat Dec 26 09:57:00 CET 2009


Thanks. I will try to fix the problems you reported this evening and
will let you know.

On Sat, Dec 26, 2009 at 2:26 AM, Nikolaus Rath <Nikolaus at rath.org> wrote:
> Hello,
>
> 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;
> };
>
> into
>
> 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)]
>
> Best,
>
>   -Nikolaus
>
> --
>  »Time flies like an arrow, fruit flies like a Banana.«
>
>  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig



-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/


More information about the Cplusplus-sig mailing list