1 #ifndef Py_ASDL_H
2 #define Py_ASDL_H
3 
4 typedef PyObject * identifier;
5 typedef PyObject * string;
6 typedef PyObject * object;
7 
8 #include <stdbool.h>
9 
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.
14 */
15 
16 /* XXX A sequence should be typed so that its use can be typechecked. */
17 
18 typedef struct {
19     int size;
20     void *elements[1];
21 } asdl_seq;
22 
23 typedef struct {
24     int size;
25     int elements[1];
26 } asdl_int_seq;
27 
28 asdl_seq *asdl_seq_new(int size, PyArena *arena);
29 asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
30 
31 #define asdl_seq_GET(S, I) (S)->elements[(I)]
32 #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
33 #ifdef Py_DEBUG
34 #define asdl_seq_SET(S, I, V) { \
35         int _asdl_i = (I); \
36         assert((S) && _asdl_i < (S)->size); \
37         (S)->elements[_asdl_i] = (V); \
38 }
39 #else
40 #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
41 #endif
42 
43 #endif /* !Py_ASDL_H */
44