1 #ifndef Py_LIMITED_API 2 #ifndef Py_ASDL_H 3 #define Py_ASDL_H 4 5 typedef PyObject * identifier; 6 typedef PyObject * string; 7 typedef PyObject * object; 8 typedef PyObject * constant; 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 Py_ssize_t size; 20 void *elements[1]; 21 } asdl_seq; 22 23 typedef struct { 24 Py_ssize_t size; 25 int elements[1]; 26 } asdl_int_seq; 27 28 asdl_seq *_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena); 29 asdl_int_seq *_Py_asdl_int_seq_new(Py_ssize_t 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 do { \ 36 Py_ssize_t _asdl_i = (I); \ 37 assert((S) != NULL); \ 38 assert(0 <= _asdl_i && _asdl_i < (S)->size); \ 39 (S)->elements[_asdl_i] = (V); \ 40 } while (0) 41 #else 42 #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V) 43 #endif 44 45 #endif /* !Py_ASDL_H */ 46 #endif /* Py_LIMITED_API */ 47