Message52637
Hello
The attached patch allows to use T_BOOL alongside other common types in the PyMemberDef definitions of your custom types.
The boolean value is assumed to be held in a straight C char variable, and PyMember_SetOne() sets it to 1 or 0 depending on the result of calling PyObject_IsTrue() on the passed value object.
Usage example:
typedef struct ButtonObject
{
PyObject_HEAD
char fToggled;
} ButtonObject;
static PyMemberDef eb_ButtonEventMembers[] = {
{ "toggled", T_BOOL, offsetof(ButtonObject, fToggled), RO, "True if the button is currently toggled" },
{ NULL, 0, 0, 0, NULL }
};
The patch has been built against a plain Python 2.5 installation.
|
|
Date |
User |
Action |
Args |
2007-08-23 15:58:28 | admin | link | issue1720595 messages |
2007-08-23 15:58:28 | admin | create | |
|