Saved and restored logging._handlerList at the same time as saving/restoring logging...
[python.git] / Include / asdl.h
bloba2c86c8dd457b842bf52c0eae5a4ae5aae9280aa
1 #ifndef Py_ASDL_H
2 #define Py_ASDL_H
4 typedef PyObject * identifier;
5 typedef PyObject * string;
6 typedef PyObject * object;
8 typedef enum {false, true} bool;
10 /* It would be nice if the code generated by asdl_c.py was completely
11 independent of Python, but it is a goal the requires too much work
12 at this stage. So, for example, I'll represent identifiers as
13 interned Python strings.
16 /* XXX A sequence should be typed so that its use can be typechecked. */
18 /* XXX We shouldn't pay for offset when we don't need APPEND. */
20 typedef struct {
21 int size;
22 int offset;
23 void *elements[1];
24 } asdl_seq;
26 asdl_seq *asdl_seq_new(int size, PyArena *arena);
27 void asdl_seq_free(asdl_seq *);
29 #ifdef Py_DEBUG
30 #define asdl_seq_GET(S, I) (S)->elements[(I)]
31 #define asdl_seq_SET(S, I, V) { \
32 int _asdl_i = (I); \
33 assert((S) && _asdl_i < (S)->size); \
34 (S)->elements[_asdl_i] = (V); \
36 #define asdl_seq_APPEND(S, V) { \
37 assert((S) && (S)->offset < (S)->size); \
38 (S)->elements[(S)->offset++] = (V); \
40 #else
41 #define asdl_seq_GET(S, I) (S)->elements[(I)]
42 #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
43 #define asdl_seq_APPEND(S, V) (S)->elements[(S)->offset++] = (V)
44 #endif
45 #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
47 #endif /* !Py_ASDL_H */