]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.10/Include/structmember.h
AppPkg/Applications/Python/Python-2.7.10: Initial Checkin part 1/5.
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Include / structmember.h
CommitLineData
c8042e10
DM
1#ifndef Py_STRUCTMEMBER_H\r
2#define Py_STRUCTMEMBER_H\r
3#ifdef __cplusplus\r
4extern "C" {\r
5#endif\r
6\r
7\r
8/* Interface to map C struct members to Python object attributes */\r
9\r
10#include <stddef.h> /* For offsetof */\r
11\r
12/* The offsetof() macro calculates the offset of a structure member\r
13 in its structure. Unfortunately this cannot be written down\r
14 portably, hence it is provided by a Standard C header file.\r
15 For pre-Standard C compilers, here is a version that usually works\r
16 (but watch out!): */\r
17\r
18#ifndef offsetof\r
19#define offsetof(type, member) ( (int) & ((type*)0) -> member )\r
20#endif\r
21\r
22/* An array of memberlist structures defines the name, type and offset\r
23 of selected members of a C structure. These can be read by\r
24 PyMember_Get() and set by PyMember_Set() (except if their READONLY flag\r
25 is set). The array must be terminated with an entry whose name\r
26 pointer is NULL. */\r
27\r
28struct memberlist {\r
29 /* Obsolete version, for binary backwards compatibility */\r
30 char *name;\r
31 int type;\r
32 int offset;\r
33 int flags;\r
34};\r
35\r
36typedef struct PyMemberDef {\r
37 /* Current version, use this */\r
38 char *name;\r
39 int type;\r
40 Py_ssize_t offset;\r
41 int flags;\r
42 char *doc;\r
43} PyMemberDef;\r
44\r
45/* Types */\r
46#define T_SHORT 0\r
47#define T_INT 1\r
48#define T_LONG 2\r
49#define T_FLOAT 3\r
50#define T_DOUBLE 4\r
51#define T_STRING 5\r
52#define T_OBJECT 6\r
53/* XXX the ordering here is weird for binary compatibility */\r
54#define T_CHAR 7 /* 1-character string */\r
55#define T_BYTE 8 /* 8-bit signed int */\r
56/* unsigned variants: */\r
57#define T_UBYTE 9\r
58#define T_USHORT 10\r
59#define T_UINT 11\r
60#define T_ULONG 12\r
61\r
62/* Added by Jack: strings contained in the structure */\r
63#define T_STRING_INPLACE 13\r
64\r
65/* Added by Lillo: bools contained in the structure (assumed char) */\r
66#define T_BOOL 14\r
67\r
68#define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError\r
69 when the value is NULL, instead of\r
70 converting to None. */\r
71#ifdef HAVE_LONG_LONG\r
72#define T_LONGLONG 17\r
73#define T_ULONGLONG 18\r
74#endif /* HAVE_LONG_LONG */\r
75\r
76#define T_PYSSIZET 19 /* Py_ssize_t */\r
77\r
78\r
79/* Flags */\r
80#define READONLY 1\r
81#define RO READONLY /* Shorthand */\r
82#define READ_RESTRICTED 2\r
83#define PY_WRITE_RESTRICTED 4\r
84#define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED)\r
85\r
86\r
87/* Obsolete API, for binary backwards compatibility */\r
88PyAPI_FUNC(PyObject *) PyMember_Get(const char *, struct memberlist *, const char *);\r
89PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, const char *, PyObject *);\r
90\r
91/* Current API, use this */\r
92PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *);\r
93PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *);\r
94\r
95\r
96#ifdef __cplusplus\r
97}\r
98#endif\r
99#endif /* !Py_STRUCTMEMBER_H */\r