summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2006-04-13 09:37:01 (GMT)
committerSkip Montanaro <skip@pobox.com>2006-04-13 09:37:01 (GMT)
commitb9406711864885c8434c9ba41da90f7ea1e18a47 (patch)
treee69b327ed5e617041beff1fdfae844d7d994526b /Include
parent83687c98dcb1deb6c0e7091e2f9df7dbeae56910 (diff)
downloadcpython-b9406711864885c8434c9ba41da90f7ea1e18a47.zip
cpython-b9406711864885c8434c9ba41da90f7ea1e18a47.tar.gz
cpython-b9406711864885c8434c9ba41da90f7ea1e18a47.tar.bz2
Use union to discriminate pointer types from enum/int types.
Diffstat (limited to 'Include')
-rw-r--r--Include/asdl.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/Include/asdl.h b/Include/asdl.h
index d709d42..6a9adea 100644
--- a/Include/asdl.h
+++ b/Include/asdl.h
@@ -19,18 +19,22 @@ typedef enum {false, true} bool;
typedef struct {
int size;
- void *elements[1];
+ union {
+ void *elements[1];
+ unsigned int enum_type[1];
+ } elt;
} asdl_seq;
asdl_seq *asdl_seq_new(int size, PyArena *arena);
-#define asdl_seq_GET(S, I) (S)->elements[(I)]
+#define asdl_seq_GET(S, I) (S)->elt.elements[(I)]
+#define asdl_seq_GET_ENUM(S, I) (S)->elt.enum_type[(I)]
#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
#ifdef Py_DEBUG
#define asdl_seq_SET(S, I, V) { \
int _asdl_i = (I); \
assert((S) && _asdl_i < (S)->size); \
- (S)->elements[_asdl_i] = (V); \
+ (S)->elt.elements[_asdl_i] = (V); \
}
#else
#define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)