Boost logo

Boost Users :

Subject: [Boost-users] Is it possible to expose bit-fields through boost.python
From: Andy Falanga (afalanga) (afalanga_at_[hidden])
Date: 2012-02-17 14:06:26


I'd like to be able expose a struct defined as a bit field in C++ to python. Being a neophyte in Boost, I'm wondering if there's a way to doing this. I'm trying the method that I used when exposing a conventional struct, but the intellisense in Visual Studio is complaining to me that bit-fields can't be exposed. I'm sure most on this list know what I mean, but just in case:

struct bitField {
    char bit1 : 1;
    char bit2 : 1;
    char bit34 : 2;
    char bit567 : 3;
    char bit8 : 1;

    .def_readwrite("bit1", &bitField::bit1)
    .def_readwrite("bit2", &bitField::bit2)
    .def_readwrite("bit34", &bitField::bit34)
    .def_readwrite("bit567", &bitField::bit567)
    .def_readwrite("bit8", &bitField::bit8)

Is there a way of doing this? This pattern is what I used to expose a conventional struct.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at