1 #ifndef Py_ASDL_H
2 #define Py_ASDL_H
3 
4 typedef PyObject * identifier;
5 typedef PyObject * string;
6 typedef PyObject * bytes;
7 typedef PyObject * object;
8 typedef PyObject * singleton;
9 typedef PyObject * constant;
10 
11 /* It would be nice if the code generated by asdl_c.py was completely
12    independent of Python, but it is a goal the requires too much work
13    at this stage.  So, for example, I'll represent identifiers as
14    interned Python strings.
15 */
16 
17 /* XXX A sequence should be typed so that its use can be typechecked. */
18 
19 typedef struct {
20     Py_ssize_t size;
21     void *elements[1];
22 } asdl_seq;
23 
24 typedef struct {
25     Py_ssize_t size;
26     int elements[1];
27 } asdl_int_seq;
28 
29 asdl_seq *_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena);
30 asdl_int_seq *_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena);
31 
32 #define asdl_seq_GET(S, I) (S)->elements[(I)]
33 #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
34 #ifdef Py_DEBUG
35 #define asdl_seq_SET(S, I, V) \
36     do { \
37         Py_ssize_t _asdl_i = (I); \
38         assert((S) != NULL); \
39         assert(_asdl_i < (S)->size); \
40         (S)->elements[_asdl_i] = (V); \
41     } while (0)
42 #else
43 #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
44 #endif
45 
46 #endif /* !Py_ASDL_H */
47