Mercurial > cpython-lru_cache-weakref
annotate Include/asdl.h @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 5e72b0c74100 |
| children |
| rev | line source |
|---|---|
| 35742 | 1 #ifndef Py_ASDL_H |
| 2 #define Py_ASDL_H | |
| 3 | |
| 4 typedef PyObject * identifier; | |
| 5 typedef PyObject * string; | |
| 6 typedef PyObject * object; | |
| 7 | |
|
37595
0591d0322f04
C++ already defines a perfectly good 'bool'. Use that.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
36718
diff
changeset
|
8 #ifndef __cplusplus |
| 35742 | 9 typedef enum {false, true} bool; |
|
37595
0591d0322f04
C++ already defines a perfectly good 'bool'. Use that.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
36718
diff
changeset
|
10 #endif |
| 35742 | 11 |
| 12 /* It would be nice if the code generated by asdl_c.py was completely | |
| 13 independent of Python, but it is a goal the requires too much work | |
| 14 at this stage. So, for example, I'll represent identifiers as | |
| 15 interned Python strings. | |
| 16 */ | |
| 17 | |
| 18 /* XXX A sequence should be typed so that its use can be typechecked. */ | |
| 19 | |
| 20 typedef struct { | |
| 21 int size; | |
|
37680
fe88e01ff6de
revert - breaks build of Python/ast.c w/ gcc
Skip Montanaro <skip@pobox.com>
parents:
37679
diff
changeset
|
22 void *elements[1]; |
| 35742 | 23 } asdl_seq; |
| 24 | |
|
37685
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
37680
diff
changeset
|
25 typedef struct { |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
37680
diff
changeset
|
26 int size; |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
37680
diff
changeset
|
27 int elements[1]; |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
37680
diff
changeset
|
28 } asdl_int_seq; |
|
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
37680
diff
changeset
|
29 |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
35866
diff
changeset
|
30 asdl_seq *asdl_seq_new(int size, PyArena *arena); |
|
37685
5e72b0c74100
Introduce asdl_int_seq, to hold cmpop_ty.
Martin v. Löwis <martin@v.loewis.de>
parents:
37680
diff
changeset
|
31 asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena); |
| 35742 | 32 |
|
37680
fe88e01ff6de
revert - breaks build of Python/ast.c w/ gcc
Skip Montanaro <skip@pobox.com>
parents:
37679
diff
changeset
|
33 #define asdl_seq_GET(S, I) (S)->elements[(I)] |
|
36718
45e6f901902c
Remove asdl_seq_APPEND() and simplify asdl seq implementation.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
36065
diff
changeset
|
34 #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size) |
| 35742 | 35 #ifdef Py_DEBUG |
| 36 #define asdl_seq_SET(S, I, V) { \ | |
| 37 int _asdl_i = (I); \ | |
| 38 assert((S) && _asdl_i < (S)->size); \ | |
|
37680
fe88e01ff6de
revert - breaks build of Python/ast.c w/ gcc
Skip Montanaro <skip@pobox.com>
parents:
37679
diff
changeset
|
39 (S)->elements[_asdl_i] = (V); \ |
| 35742 | 40 } |
| 41 #else | |
| 42 #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V) | |
| 43 #endif | |
| 44 | |
| 45 #endif /* !Py_ASDL_H */ |
