Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 36174:85b2d804ac0a legacy-trunk
Regenerate.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Mon, 02 Jan 2006 21:18:55 +0000 |
| parents | ea083efdc96c |
| children | 3c0b26113df6 |
comparison
equal
deleted
inserted
replaced
| 36173:ade46371f04b | 36174:85b2d804ac0a |
|---|---|
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 | 1098 |
| 1099 | 1099 |
| 1100 #define CHECKSIZE(BUF, OFF, MIN) { \ | 1100 #define CHECKSIZE(BUF, OFF, MIN) { \ |
| 1101 int need = *(OFF) + MIN; \ | 1101 int need = *(OFF) + MIN; \ |
| 1102 if (need >= PyString_GET_SIZE(*(BUF))) { \ | 1102 if (need >= PyString_GET_SIZE(*(BUF))) { \ |
| 1103 int newsize = PyString_GET_SIZE(*(BUF)) * 2; \ | 1103 int newsize = PyString_GET_SIZE(*(BUF)) * 2; \ |
| 1104 if (newsize < need) \ | 1104 if (newsize < need) \ |
| 1105 newsize = need; \ | 1105 newsize = need; \ |
| 1106 if (_PyString_Resize((BUF), newsize) < 0) \ | 1106 if (_PyString_Resize((BUF), newsize) < 0) \ |
| 1107 return 0; \ | 1107 return 0; \ |
| 1108 } \ | 1108 } \ |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 static int | 1111 static int |
| 1112 marshal_write_int(PyObject **buf, int *offset, int x) | 1112 marshal_write_int(PyObject **buf, int *offset, int x) |
| 1113 { | 1113 { |
| 1114 char *s; | 1114 char *s; |
| 1115 | 1115 |
| 1116 CHECKSIZE(buf, offset, 4) | 1116 CHECKSIZE(buf, offset, 4) |
| 1117 s = PyString_AS_STRING(*buf) + (*offset); | 1117 s = PyString_AS_STRING(*buf) + (*offset); |
| 1118 s[0] = (x & 0xff); | 1118 s[0] = (x & 0xff); |
| 1119 s[1] = (x >> 8) & 0xff; | 1119 s[1] = (x >> 8) & 0xff; |
| 1120 s[2] = (x >> 16) & 0xff; | 1120 s[2] = (x >> 16) & 0xff; |
| 1121 s[3] = (x >> 24) & 0xff; | 1121 s[3] = (x >> 24) & 0xff; |
| 1122 *offset += 4; | 1122 *offset += 4; |
| 1123 return 1; | 1123 return 1; |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 static int | 1126 static int |
| 1127 marshal_write_bool(PyObject **buf, int *offset, bool b) | 1127 marshal_write_bool(PyObject **buf, int *offset, bool b) |
| 1128 { | 1128 { |
| 1129 if (b) | 1129 if (b) |
| 1130 marshal_write_int(buf, offset, 1); | 1130 marshal_write_int(buf, offset, 1); |
| 1131 else | 1131 else |
| 1132 marshal_write_int(buf, offset, 0); | 1132 marshal_write_int(buf, offset, 0); |
| 1133 return 1; | 1133 return 1; |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 static int | 1136 static int |
| 1137 marshal_write_identifier(PyObject **buf, int *offset, identifier id) | 1137 marshal_write_identifier(PyObject **buf, int *offset, identifier id) |
| 1138 { | 1138 { |
| 1139 int l = PyString_GET_SIZE(id); | 1139 int l = PyString_GET_SIZE(id); |
| 1140 marshal_write_int(buf, offset, l); | 1140 marshal_write_int(buf, offset, l); |
| 1141 CHECKSIZE(buf, offset, l); | 1141 CHECKSIZE(buf, offset, l); |
| 1142 memcpy(PyString_AS_STRING(*buf) + *offset, | 1142 memcpy(PyString_AS_STRING(*buf) + *offset, |
| 1143 PyString_AS_STRING(id), l); | 1143 PyString_AS_STRING(id), l); |
| 1144 *offset += l; | 1144 *offset += l; |
| 1145 return 1; | 1145 return 1; |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 static int | 1148 static int |
| 1149 marshal_write_string(PyObject **buf, int *offset, string s) | 1149 marshal_write_string(PyObject **buf, int *offset, string s) |
| 1150 { | 1150 { |
| 1151 int len = PyString_GET_SIZE(s); | 1151 int len = PyString_GET_SIZE(s); |
| 1152 marshal_write_int(buf, offset, len); | 1152 marshal_write_int(buf, offset, len); |
| 1153 CHECKSIZE(buf, offset, len); | 1153 CHECKSIZE(buf, offset, len); |
| 1154 memcpy(PyString_AS_STRING(*buf) + *offset, | 1154 memcpy(PyString_AS_STRING(*buf) + *offset, |
| 1155 PyString_AS_STRING(s), len); | 1155 PyString_AS_STRING(s), len); |
| 1156 *offset += len; | 1156 *offset += len; |
| 1157 return 1; | 1157 return 1; |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 static int | 1160 static int |
| 1161 marshal_write_object(PyObject **buf, int *offset, object s) | 1161 marshal_write_object(PyObject **buf, int *offset, object s) |
| 1162 { | 1162 { |
| 1163 /* XXX */ | 1163 /* XXX */ |
| 1164 return 0; | 1164 return 0; |
| 1165 } | 1165 } |
| 1166 | 1166 |
| 1167 | 1167 |
| 1168 static int | 1168 static int |
| 1169 marshal_write_mod(PyObject **buf, int *off, mod_ty o) | 1169 marshal_write_mod(PyObject **buf, int *off, mod_ty o) |
