Merged revisions 82952,82954 via svnmerge from
[python/dscho.git] / Include / asdl.h
blob9bb06978da2608a8413acd046f282157a22a023c
1 #ifndef Py_ASDL_H
2 #define Py_ASDL_H
4 typedef PyObject * identifier;
5 typedef PyObject * string;
6 typedef PyObject * object;
8 /* It would be nice if the code generated by asdl_c.py was completely
9 independent of Python, but it is a goal the requires too much work
10 at this stage. So, for example, I'll represent identifiers as
11 interned Python strings.
14 /* XXX A sequence should be typed so that its use can be typechecked. */
16 typedef struct {
17 int size;
18 void *elements[1];
19 } asdl_seq;
21 typedef struct {
22 int size;
23 int elements[1];
24 } asdl_int_seq;
26 asdl_seq *asdl_seq_new(int size, PyArena *arena);
27 asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
29 #define asdl_seq_GET(S, I) (S)->elements[(I)]
30 #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
31 #ifdef Py_DEBUG
32 #define asdl_seq_SET(S, I, V) { \
33 int _asdl_i = (I); \
34 assert((S) && _asdl_i < (S)->size); \
35 (S)->elements[_asdl_i] = (V); \
37 #else
38 #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
39 #endif
41 #endif /* !Py_ASDL_H */