Chris@87: #ifndef Py_ASDL_H Chris@87: #define Py_ASDL_H Chris@87: Chris@87: typedef PyObject * identifier; Chris@87: typedef PyObject * string; Chris@87: typedef PyObject * object; Chris@87: Chris@87: #ifndef __cplusplus Chris@87: typedef enum {false, true} bool; Chris@87: #endif Chris@87: Chris@87: /* It would be nice if the code generated by asdl_c.py was completely Chris@87: independent of Python, but it is a goal the requires too much work Chris@87: at this stage. So, for example, I'll represent identifiers as Chris@87: interned Python strings. Chris@87: */ Chris@87: Chris@87: /* XXX A sequence should be typed so that its use can be typechecked. */ Chris@87: Chris@87: typedef struct { Chris@87: int size; Chris@87: void *elements[1]; Chris@87: } asdl_seq; Chris@87: Chris@87: typedef struct { Chris@87: int size; Chris@87: int elements[1]; Chris@87: } asdl_int_seq; Chris@87: Chris@87: asdl_seq *asdl_seq_new(int size, PyArena *arena); Chris@87: asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena); Chris@87: Chris@87: #define asdl_seq_GET(S, I) (S)->elements[(I)] Chris@87: #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size) Chris@87: #ifdef Py_DEBUG Chris@87: #define asdl_seq_SET(S, I, V) { \ Chris@87: int _asdl_i = (I); \ Chris@87: assert((S) && _asdl_i < (S)->size); \ Chris@87: (S)->elements[_asdl_i] = (V); \ Chris@87: } Chris@87: #else Chris@87: #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V) Chris@87: #endif Chris@87: Chris@87: #endif /* !Py_ASDL_H */