| 1 |
#ifndef Py_STRUCTMEMBER_H |
| 2 |
#define Py_STRUCTMEMBER_H |
| 3 |
#ifdef __cplusplus |
| 4 |
extern "C" { |
| 5 |
#endif |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#include <stddef.h> |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef offsetof |
| 19 |
#define offsetof(type, member) ( (int) & ((type*)0) -> member ) |
| 20 |
#endif |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
struct memberlist { |
| 29 |
|
| 30 |
char *name; |
| 31 |
int type; |
| 32 |
int offset; |
| 33 |
int flags; |
| 34 |
}; |
| 35 |
|
| 36 |
typedef struct PyMemberDef { |
| 37 |
|
| 38 |
char *name; |
| 39 |
int type; |
| 40 |
Py_ssize_t offset; |
| 41 |
int flags; |
| 42 |
char *doc; |
| 43 |
} PyMemberDef; |
| 44 |
|
| 45 |
|
| 46 |
#define T_SHORT 0 |
| 47 |
#define T_INT 1 |
| 48 |
#define T_LONG 2 |
| 49 |
#define T_FLOAT 3 |
| 50 |
#define T_DOUBLE 4 |
| 51 |
#define T_STRING 5 |
| 52 |
#define T_OBJECT 6 |
| 53 |
|
| 54 |
#define T_CHAR 7 |
| 55 |
#define T_BYTE 8 |
| 56 |
|
| 57 |
#define T_UBYTE 9 |
| 58 |
#define T_USHORT 10 |
| 59 |
#define T_UINT 11 |
| 60 |
#define T_ULONG 12 |
| 61 |
|
| 62 |
|
| 63 |
#define T_STRING_INPLACE 13 |
| 64 |
|
| 65 |
|
| 66 |
#define T_BOOL 14 |
| 67 |
|
| 68 |
#define T_OBJECT_EX 16 |
| 69 |
|
| 70 |
|
| 71 |
#ifdef HAVE_LONG_LONG |
| 72 |
#define T_LONGLONG 17 |
| 73 |
#define T_ULONGLONG 18 |
| 74 |
#endif |
| 75 |
|
| 76 |
#define T_PYSSIZET 19 |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
#define READONLY 1 |
| 81 |
#define RO READONLY |
| 82 |
#define READ_RESTRICTED 2 |
| 83 |
#define PY_WRITE_RESTRICTED 4 |
| 84 |
#define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED) |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
PyAPI_FUNC(PyObject *) PyMember_Get(const char *, struct memberlist *, const char *); |
| 89 |
PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, const char *, PyObject *); |
| 90 |
|
| 91 |
|
| 92 |
PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *); |
| 93 |
PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *); |
| 94 |
|
| 95 |
|
| 96 |
#ifdef __cplusplus |
| 97 |
} |
| 98 |
#endif |
| 99 |
#endif |