summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2005-11-13 19:14:20 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2005-11-13 19:14:20 (GMT)
commit7b5a604d247e8446dbcb208ab2b1e231eff1e9cf (patch)
tree4e5a45b76fbc7efe4f586318fe22ee40eb9aab18 /Python
parent497b19a8a2c1275709ad7490e4c11750ede026fb (diff)
downloadcpython-7b5a604d247e8446dbcb208ab2b1e231eff1e9cf.zip
cpython-7b5a604d247e8446dbcb208ab2b1e231eff1e9cf.tar.gz
cpython-7b5a604d247e8446dbcb208ab2b1e231eff1e9cf.tar.bz2
Whoops, checkin consistent versions of *all* files to stop polluting
a bunch of names
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c74
-rw-r--r--Python/asdl.c66
2 files changed, 74 insertions, 66 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 677705c..14040ad 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -17,6 +17,7 @@ static int marshal_write_excepthandler(PyObject **, int *, excepthandler_ty);
static int marshal_write_arguments(PyObject **, int *, arguments_ty);
static int marshal_write_keyword(PyObject **, int *, keyword_ty);
static int marshal_write_alias(PyObject **, int *, alias_ty);
+
mod_ty
Module(asdl_seq * body)
{
@@ -1087,6 +1088,7 @@ alias(identifier name, identifier asname)
return p;
}
+
static void
free_seq_exprs(asdl_seq *seq)
{
@@ -1107,6 +1109,7 @@ free_seq_stmts(asdl_seq *seq)
asdl_seq_free(seq);
}
+
void
free_mod(mod_ty o)
{
@@ -1533,6 +1536,76 @@ free_alias(alias_ty o)
free(o);
}
+
+
+#define CHECKSIZE(BUF, OFF, MIN) { \
+ int need = *(OFF) + MIN; \
+ if (need >= PyString_GET_SIZE(*(BUF))) { \
+ int newsize = PyString_GET_SIZE(*(BUF)) * 2; \
+ if (newsize < need) \
+ newsize = need; \
+ if (_PyString_Resize((BUF), newsize) < 0) \
+ return 0; \
+ } \
+}
+
+static int
+marshal_write_int(PyObject **buf, int *offset, int x)
+{
+ char *s;
+
+ CHECKSIZE(buf, offset, 4)
+ s = PyString_AS_STRING(*buf) + (*offset);
+ s[0] = (x & 0xff);
+ s[1] = (x >> 8) & 0xff;
+ s[2] = (x >> 16) & 0xff;
+ s[3] = (x >> 24) & 0xff;
+ *offset += 4;
+ return 1;
+}
+
+static int
+marshal_write_bool(PyObject **buf, int *offset, bool b)
+{
+ if (b)
+ marshal_write_int(buf, offset, 1);
+ else
+ marshal_write_int(buf, offset, 0);
+ return 1;
+}
+
+static int
+marshal_write_identifier(PyObject **buf, int *offset, identifier id)
+{
+ int l = PyString_GET_SIZE(id);
+ marshal_write_int(buf, offset, l);
+ CHECKSIZE(buf, offset, l);
+ memcpy(PyString_AS_STRING(*buf) + *offset,
+ PyString_AS_STRING(id), l);
+ *offset += l;
+ return 1;
+}
+
+static int
+marshal_write_string(PyObject **buf, int *offset, string s)
+{
+ int len = PyString_GET_SIZE(s);
+ marshal_write_int(buf, offset, len);
+ CHECKSIZE(buf, offset, len);
+ memcpy(PyString_AS_STRING(*buf) + *offset,
+ PyString_AS_STRING(s), len);
+ *offset += len;
+ return 1;
+}
+
+static int
+marshal_write_object(PyObject **buf, int *offset, object s)
+{
+ /* XXX */
+ return 0;
+}
+
+
static int
marshal_write_mod(PyObject **buf, int *off, mod_ty o)
{
@@ -2286,3 +2359,4 @@ marshal_write_alias(PyObject **buf, int *off, alias_ty o)
return 1;
}
+
diff --git a/Python/asdl.c b/Python/asdl.c
index bb29857..efd345e 100644
--- a/Python/asdl.c
+++ b/Python/asdl.c
@@ -24,69 +24,3 @@ asdl_seq_free(asdl_seq *seq)
PyObject_Free(seq);
}
-#define CHECKSIZE(BUF, OFF, MIN) { \
- int need = *(OFF) + MIN; \
- if (need >= PyString_GET_SIZE(*(BUF))) { \
- int newsize = PyString_GET_SIZE(*(BUF)) * 2; \
- if (newsize < need) \
- newsize = need; \
- if (_PyString_Resize((BUF), newsize) < 0) \
- return 0; \
- } \
-}
-
-int
-marshal_write_int(PyObject **buf, int *offset, int x)
-{
- char *s;
-
- CHECKSIZE(buf, offset, 4)
- s = PyString_AS_STRING(*buf) + (*offset);
- s[0] = (x & 0xff);
- s[1] = (x >> 8) & 0xff;
- s[2] = (x >> 16) & 0xff;
- s[3] = (x >> 24) & 0xff;
- *offset += 4;
- return 1;
-}
-
-int
-marshal_write_bool(PyObject **buf, int *offset, bool b)
-{
- if (b)
- marshal_write_int(buf, offset, 1);
- else
- marshal_write_int(buf, offset, 0);
- return 1;
-}
-
-int
-marshal_write_identifier(PyObject **buf, int *offset, identifier id)
-{
- int l = PyString_GET_SIZE(id);
- marshal_write_int(buf, offset, l);
- CHECKSIZE(buf, offset, l);
- memcpy(PyString_AS_STRING(*buf) + *offset,
- PyString_AS_STRING(id), l);
- *offset += l;
- return 1;
-}
-
-int
-marshal_write_string(PyObject **buf, int *offset, string s)
-{
- int len = PyString_GET_SIZE(s);
- marshal_write_int(buf, offset, len);
- CHECKSIZE(buf, offset, len);
- memcpy(PyString_AS_STRING(*buf) + *offset,
- PyString_AS_STRING(s), len);
- *offset += len;
- return 1;
-}
-
-int
-marshal_write_object(PyObject **buf, int *offset, object s)
-{
- /* XXX */
- return 0;
-}