comparison Python/Python-ast.c @ 72925:7109f31300fb

Rename _Py_identifier to _Py_IDENTIFIER.
author Martin v. Löwis <martin@v.loewis.de>
date Fri, 14 Oct 2011 10:20:37 +0200
parents 81380082d216
children db4aa878cea2
comparison
equal deleted inserted replaced
72924:158430b2b552 72925:7109f31300fb
5 5
6 static PyTypeObject AST_type; 6 static PyTypeObject AST_type;
7 static PyTypeObject *mod_type; 7 static PyTypeObject *mod_type;
8 static PyObject* ast2obj_mod(void*); 8 static PyObject* ast2obj_mod(void*);
9 static PyTypeObject *Module_type; 9 static PyTypeObject *Module_type;
10 _Py_identifier(body); 10 _Py_IDENTIFIER(body);
11 static char *Module_fields[]={ 11 static char *Module_fields[]={
12 "body", 12 "body",
13 }; 13 };
14 static PyTypeObject *Interactive_type; 14 static PyTypeObject *Interactive_type;
15 static char *Interactive_fields[]={ 15 static char *Interactive_fields[]={
22 static PyTypeObject *Suite_type; 22 static PyTypeObject *Suite_type;
23 static char *Suite_fields[]={ 23 static char *Suite_fields[]={
24 "body", 24 "body",
25 }; 25 };
26 static PyTypeObject *stmt_type; 26 static PyTypeObject *stmt_type;
27 _Py_identifier(lineno); 27 _Py_IDENTIFIER(lineno);
28 _Py_identifier(col_offset); 28 _Py_IDENTIFIER(col_offset);
29 static char *stmt_attributes[] = { 29 static char *stmt_attributes[] = {
30 "lineno", 30 "lineno",
31 "col_offset", 31 "col_offset",
32 }; 32 };
33 static PyObject* ast2obj_stmt(void*); 33 static PyObject* ast2obj_stmt(void*);
34 static PyTypeObject *FunctionDef_type; 34 static PyTypeObject *FunctionDef_type;
35 _Py_identifier(name); 35 _Py_IDENTIFIER(name);
36 _Py_identifier(args); 36 _Py_IDENTIFIER(args);
37 _Py_identifier(decorator_list); 37 _Py_IDENTIFIER(decorator_list);
38 _Py_identifier(returns); 38 _Py_IDENTIFIER(returns);
39 static char *FunctionDef_fields[]={ 39 static char *FunctionDef_fields[]={
40 "name", 40 "name",
41 "args", 41 "args",
42 "body", 42 "body",
43 "decorator_list", 43 "decorator_list",
44 "returns", 44 "returns",
45 }; 45 };
46 static PyTypeObject *ClassDef_type; 46 static PyTypeObject *ClassDef_type;
47 _Py_identifier(bases); 47 _Py_IDENTIFIER(bases);
48 _Py_identifier(keywords); 48 _Py_IDENTIFIER(keywords);
49 _Py_identifier(starargs); 49 _Py_IDENTIFIER(starargs);
50 _Py_identifier(kwargs); 50 _Py_IDENTIFIER(kwargs);
51 static char *ClassDef_fields[]={ 51 static char *ClassDef_fields[]={
52 "name", 52 "name",
53 "bases", 53 "bases",
54 "keywords", 54 "keywords",
55 "starargs", 55 "starargs",
56 "kwargs", 56 "kwargs",
57 "body", 57 "body",
58 "decorator_list", 58 "decorator_list",
59 }; 59 };
60 static PyTypeObject *Return_type; 60 static PyTypeObject *Return_type;
61 _Py_identifier(value); 61 _Py_IDENTIFIER(value);
62 static char *Return_fields[]={ 62 static char *Return_fields[]={
63 "value", 63 "value",
64 }; 64 };
65 static PyTypeObject *Delete_type; 65 static PyTypeObject *Delete_type;
66 _Py_identifier(targets); 66 _Py_IDENTIFIER(targets);
67 static char *Delete_fields[]={ 67 static char *Delete_fields[]={
68 "targets", 68 "targets",
69 }; 69 };
70 static PyTypeObject *Assign_type; 70 static PyTypeObject *Assign_type;
71 static char *Assign_fields[]={ 71 static char *Assign_fields[]={
72 "targets", 72 "targets",
73 "value", 73 "value",
74 }; 74 };
75 static PyTypeObject *AugAssign_type; 75 static PyTypeObject *AugAssign_type;
76 _Py_identifier(target); 76 _Py_IDENTIFIER(target);
77 _Py_identifier(op); 77 _Py_IDENTIFIER(op);
78 static char *AugAssign_fields[]={ 78 static char *AugAssign_fields[]={
79 "target", 79 "target",
80 "op", 80 "op",
81 "value", 81 "value",
82 }; 82 };
83 static PyTypeObject *For_type; 83 static PyTypeObject *For_type;
84 _Py_identifier(iter); 84 _Py_IDENTIFIER(iter);
85 _Py_identifier(orelse); 85 _Py_IDENTIFIER(orelse);
86 static char *For_fields[]={ 86 static char *For_fields[]={
87 "target", 87 "target",
88 "iter", 88 "iter",
89 "body", 89 "body",
90 "orelse", 90 "orelse",
91 }; 91 };
92 static PyTypeObject *While_type; 92 static PyTypeObject *While_type;
93 _Py_identifier(test); 93 _Py_IDENTIFIER(test);
94 static char *While_fields[]={ 94 static char *While_fields[]={
95 "test", 95 "test",
96 "body", 96 "body",
97 "orelse", 97 "orelse",
98 }; 98 };
101 "test", 101 "test",
102 "body", 102 "body",
103 "orelse", 103 "orelse",
104 }; 104 };
105 static PyTypeObject *With_type; 105 static PyTypeObject *With_type;
106 _Py_identifier(items); 106 _Py_IDENTIFIER(items);
107 static char *With_fields[]={ 107 static char *With_fields[]={
108 "items", 108 "items",
109 "body", 109 "body",
110 }; 110 };
111 static PyTypeObject *Raise_type; 111 static PyTypeObject *Raise_type;
112 _Py_identifier(exc); 112 _Py_IDENTIFIER(exc);
113 _Py_identifier(cause); 113 _Py_IDENTIFIER(cause);
114 static char *Raise_fields[]={ 114 static char *Raise_fields[]={
115 "exc", 115 "exc",
116 "cause", 116 "cause",
117 }; 117 };
118 static PyTypeObject *Try_type; 118 static PyTypeObject *Try_type;
119 _Py_identifier(handlers); 119 _Py_IDENTIFIER(handlers);
120 _Py_identifier(finalbody); 120 _Py_IDENTIFIER(finalbody);
121 static char *Try_fields[]={ 121 static char *Try_fields[]={
122 "body", 122 "body",
123 "handlers", 123 "handlers",
124 "orelse", 124 "orelse",
125 "finalbody", 125 "finalbody",
126 }; 126 };
127 static PyTypeObject *Assert_type; 127 static PyTypeObject *Assert_type;
128 _Py_identifier(msg); 128 _Py_IDENTIFIER(msg);
129 static char *Assert_fields[]={ 129 static char *Assert_fields[]={
130 "test", 130 "test",
131 "msg", 131 "msg",
132 }; 132 };
133 static PyTypeObject *Import_type; 133 static PyTypeObject *Import_type;
134 _Py_identifier(names); 134 _Py_IDENTIFIER(names);
135 static char *Import_fields[]={ 135 static char *Import_fields[]={
136 "names", 136 "names",
137 }; 137 };
138 static PyTypeObject *ImportFrom_type; 138 static PyTypeObject *ImportFrom_type;
139 _Py_identifier(module); 139 _Py_IDENTIFIER(module);
140 _Py_identifier(level); 140 _Py_IDENTIFIER(level);
141 static char *ImportFrom_fields[]={ 141 static char *ImportFrom_fields[]={
142 "module", 142 "module",
143 "names", 143 "names",
144 "level", 144 "level",
145 }; 145 };
163 "lineno", 163 "lineno",
164 "col_offset", 164 "col_offset",
165 }; 165 };
166 static PyObject* ast2obj_expr(void*); 166 static PyObject* ast2obj_expr(void*);
167 static PyTypeObject *BoolOp_type; 167 static PyTypeObject *BoolOp_type;
168 _Py_identifier(values); 168 _Py_IDENTIFIER(values);
169 static char *BoolOp_fields[]={ 169 static char *BoolOp_fields[]={
170 "op", 170 "op",
171 "values", 171 "values",
172 }; 172 };
173 static PyTypeObject *BinOp_type; 173 static PyTypeObject *BinOp_type;
174 _Py_identifier(left); 174 _Py_IDENTIFIER(left);
175 _Py_identifier(right); 175 _Py_IDENTIFIER(right);
176 static char *BinOp_fields[]={ 176 static char *BinOp_fields[]={
177 "left", 177 "left",
178 "op", 178 "op",
179 "right", 179 "right",
180 }; 180 };
181 static PyTypeObject *UnaryOp_type; 181 static PyTypeObject *UnaryOp_type;
182 _Py_identifier(operand); 182 _Py_IDENTIFIER(operand);
183 static char *UnaryOp_fields[]={ 183 static char *UnaryOp_fields[]={
184 "op", 184 "op",
185 "operand", 185 "operand",
186 }; 186 };
187 static PyTypeObject *Lambda_type; 187 static PyTypeObject *Lambda_type;
194 "test", 194 "test",
195 "body", 195 "body",
196 "orelse", 196 "orelse",
197 }; 197 };
198 static PyTypeObject *Dict_type; 198 static PyTypeObject *Dict_type;
199 _Py_identifier(keys); 199 _Py_IDENTIFIER(keys);
200 static char *Dict_fields[]={ 200 static char *Dict_fields[]={
201 "keys", 201 "keys",
202 "values", 202 "values",
203 }; 203 };
204 static PyTypeObject *Set_type; 204 static PyTypeObject *Set_type;
205 _Py_identifier(elts); 205 _Py_IDENTIFIER(elts);
206 static char *Set_fields[]={ 206 static char *Set_fields[]={
207 "elts", 207 "elts",
208 }; 208 };
209 static PyTypeObject *ListComp_type; 209 static PyTypeObject *ListComp_type;
210 _Py_identifier(elt); 210 _Py_IDENTIFIER(elt);
211 _Py_identifier(generators); 211 _Py_IDENTIFIER(generators);
212 static char *ListComp_fields[]={ 212 static char *ListComp_fields[]={
213 "elt", 213 "elt",
214 "generators", 214 "generators",
215 }; 215 };
216 static PyTypeObject *SetComp_type; 216 static PyTypeObject *SetComp_type;
217 static char *SetComp_fields[]={ 217 static char *SetComp_fields[]={
218 "elt", 218 "elt",
219 "generators", 219 "generators",
220 }; 220 };
221 static PyTypeObject *DictComp_type; 221 static PyTypeObject *DictComp_type;
222 _Py_identifier(key); 222 _Py_IDENTIFIER(key);
223 static char *DictComp_fields[]={ 223 static char *DictComp_fields[]={
224 "key", 224 "key",
225 "value", 225 "value",
226 "generators", 226 "generators",
227 }; 227 };
233 static PyTypeObject *Yield_type; 233 static PyTypeObject *Yield_type;
234 static char *Yield_fields[]={ 234 static char *Yield_fields[]={
235 "value", 235 "value",
236 }; 236 };
237 static PyTypeObject *Compare_type; 237 static PyTypeObject *Compare_type;
238 _Py_identifier(ops); 238 _Py_IDENTIFIER(ops);
239 _Py_identifier(comparators); 239 _Py_IDENTIFIER(comparators);
240 static char *Compare_fields[]={ 240 static char *Compare_fields[]={
241 "left", 241 "left",
242 "ops", 242 "ops",
243 "comparators", 243 "comparators",
244 }; 244 };
245 static PyTypeObject *Call_type; 245 static PyTypeObject *Call_type;
246 _Py_identifier(func); 246 _Py_IDENTIFIER(func);
247 static char *Call_fields[]={ 247 static char *Call_fields[]={
248 "func", 248 "func",
249 "args", 249 "args",
250 "keywords", 250 "keywords",
251 "starargs", 251 "starargs",
252 "kwargs", 252 "kwargs",
253 }; 253 };
254 static PyTypeObject *Num_type; 254 static PyTypeObject *Num_type;
255 _Py_identifier(n); 255 _Py_IDENTIFIER(n);
256 static char *Num_fields[]={ 256 static char *Num_fields[]={
257 "n", 257 "n",
258 }; 258 };
259 static PyTypeObject *Str_type; 259 static PyTypeObject *Str_type;
260 _Py_identifier(s); 260 _Py_IDENTIFIER(s);
261 static char *Str_fields[]={ 261 static char *Str_fields[]={
262 "s", 262 "s",
263 }; 263 };
264 static PyTypeObject *Bytes_type; 264 static PyTypeObject *Bytes_type;
265 static char *Bytes_fields[]={ 265 static char *Bytes_fields[]={
266 "s", 266 "s",
267 }; 267 };
268 static PyTypeObject *Ellipsis_type; 268 static PyTypeObject *Ellipsis_type;
269 static PyTypeObject *Attribute_type; 269 static PyTypeObject *Attribute_type;
270 _Py_identifier(attr); 270 _Py_IDENTIFIER(attr);
271 _Py_identifier(ctx); 271 _Py_IDENTIFIER(ctx);
272 static char *Attribute_fields[]={ 272 static char *Attribute_fields[]={
273 "value", 273 "value",
274 "attr", 274 "attr",
275 "ctx", 275 "ctx",
276 }; 276 };
277 static PyTypeObject *Subscript_type; 277 static PyTypeObject *Subscript_type;
278 _Py_identifier(slice); 278 _Py_IDENTIFIER(slice);
279 static char *Subscript_fields[]={ 279 static char *Subscript_fields[]={
280 "value", 280 "value",
281 "slice", 281 "slice",
282 "ctx", 282 "ctx",
283 }; 283 };
285 static char *Starred_fields[]={ 285 static char *Starred_fields[]={
286 "value", 286 "value",
287 "ctx", 287 "ctx",
288 }; 288 };
289 static PyTypeObject *Name_type; 289 static PyTypeObject *Name_type;
290 _Py_identifier(id); 290 _Py_IDENTIFIER(id);
291 static char *Name_fields[]={ 291 static char *Name_fields[]={
292 "id", 292 "id",
293 "ctx", 293 "ctx",
294 }; 294 };
295 static PyTypeObject *List_type; 295 static PyTypeObject *List_type;
313 static PyTypeObject *AugStore_type; 313 static PyTypeObject *AugStore_type;
314 static PyTypeObject *Param_type; 314 static PyTypeObject *Param_type;
315 static PyTypeObject *slice_type; 315 static PyTypeObject *slice_type;
316 static PyObject* ast2obj_slice(void*); 316 static PyObject* ast2obj_slice(void*);
317 static PyTypeObject *Slice_type; 317 static PyTypeObject *Slice_type;
318 _Py_identifier(lower); 318 _Py_IDENTIFIER(lower);
319 _Py_identifier(upper); 319 _Py_IDENTIFIER(upper);
320 _Py_identifier(step); 320 _Py_IDENTIFIER(step);
321 static char *Slice_fields[]={ 321 static char *Slice_fields[]={
322 "lower", 322 "lower",
323 "upper", 323 "upper",
324 "step", 324 "step",
325 }; 325 };
326 static PyTypeObject *ExtSlice_type; 326 static PyTypeObject *ExtSlice_type;
327 _Py_identifier(dims); 327 _Py_IDENTIFIER(dims);
328 static char *ExtSlice_fields[]={ 328 static char *ExtSlice_fields[]={
329 "dims", 329 "dims",
330 }; 330 };
331 static PyTypeObject *Index_type; 331 static PyTypeObject *Index_type;
332 static char *Index_fields[]={ 332 static char *Index_fields[]={
378 static PyTypeObject *IsNot_type; 378 static PyTypeObject *IsNot_type;
379 static PyTypeObject *In_type; 379 static PyTypeObject *In_type;
380 static PyTypeObject *NotIn_type; 380 static PyTypeObject *NotIn_type;
381 static PyTypeObject *comprehension_type; 381 static PyTypeObject *comprehension_type;
382 static PyObject* ast2obj_comprehension(void*); 382 static PyObject* ast2obj_comprehension(void*);
383 _Py_identifier(ifs); 383 _Py_IDENTIFIER(ifs);
384 static char *comprehension_fields[]={ 384 static char *comprehension_fields[]={
385 "target", 385 "target",
386 "iter", 386 "iter",
387 "ifs", 387 "ifs",
388 }; 388 };
391 "lineno", 391 "lineno",
392 "col_offset", 392 "col_offset",
393 }; 393 };
394 static PyObject* ast2obj_excepthandler(void*); 394 static PyObject* ast2obj_excepthandler(void*);
395 static PyTypeObject *ExceptHandler_type; 395 static PyTypeObject *ExceptHandler_type;
396 _Py_identifier(type); 396 _Py_IDENTIFIER(type);
397 static char *ExceptHandler_fields[]={ 397 static char *ExceptHandler_fields[]={
398 "type", 398 "type",
399 "name", 399 "name",
400 "body", 400 "body",
401 }; 401 };
402 static PyTypeObject *arguments_type; 402 static PyTypeObject *arguments_type;
403 static PyObject* ast2obj_arguments(void*); 403 static PyObject* ast2obj_arguments(void*);
404 _Py_identifier(vararg); 404 _Py_IDENTIFIER(vararg);
405 _Py_identifier(varargannotation); 405 _Py_IDENTIFIER(varargannotation);
406 _Py_identifier(kwonlyargs); 406 _Py_IDENTIFIER(kwonlyargs);
407 _Py_identifier(kwarg); 407 _Py_IDENTIFIER(kwarg);
408 _Py_identifier(kwargannotation); 408 _Py_IDENTIFIER(kwargannotation);
409 _Py_identifier(defaults); 409 _Py_IDENTIFIER(defaults);
410 _Py_identifier(kw_defaults); 410 _Py_IDENTIFIER(kw_defaults);
411 static char *arguments_fields[]={ 411 static char *arguments_fields[]={
412 "args", 412 "args",
413 "vararg", 413 "vararg",
414 "varargannotation", 414 "varargannotation",
415 "kwonlyargs", 415 "kwonlyargs",
418 "defaults", 418 "defaults",
419 "kw_defaults", 419 "kw_defaults",
420 }; 420 };
421 static PyTypeObject *arg_type; 421 static PyTypeObject *arg_type;
422 static PyObject* ast2obj_arg(void*); 422 static PyObject* ast2obj_arg(void*);
423 _Py_identifier(arg); 423 _Py_IDENTIFIER(arg);
424 _Py_identifier(annotation); 424 _Py_IDENTIFIER(annotation);
425 static char *arg_fields[]={ 425 static char *arg_fields[]={
426 "arg", 426 "arg",
427 "annotation", 427 "annotation",
428 }; 428 };
429 static PyTypeObject *keyword_type; 429 static PyTypeObject *keyword_type;
432 "arg", 432 "arg",
433 "value", 433 "value",
434 }; 434 };
435 static PyTypeObject *alias_type; 435 static PyTypeObject *alias_type;
436 static PyObject* ast2obj_alias(void*); 436 static PyObject* ast2obj_alias(void*);
437 _Py_identifier(asname); 437 _Py_IDENTIFIER(asname);
438 static char *alias_fields[]={ 438 static char *alias_fields[]={
439 "name", 439 "name",
440 "asname", 440 "asname",
441 }; 441 };
442 static PyTypeObject *withitem_type; 442 static PyTypeObject *withitem_type;
443 static PyObject* ast2obj_withitem(void*); 443 static PyObject* ast2obj_withitem(void*);
444 _Py_identifier(context_expr); 444 _Py_IDENTIFIER(context_expr);
445 _Py_identifier(optional_vars); 445 _Py_IDENTIFIER(optional_vars);
446 static char *withitem_fields[]={ 446 static char *withitem_fields[]={
447 "context_expr", 447 "context_expr",
448 "optional_vars", 448 "optional_vars",
449 }; 449 };
450 450
451 451
452 static int 452 static int
453 ast_type_init(PyObject *self, PyObject *args, PyObject *kw) 453 ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
454 { 454 {
455 _Py_identifier(_fields); 455 _Py_IDENTIFIER(_fields);
456 Py_ssize_t i, numfields = 0; 456 Py_ssize_t i, numfields = 0;
457 int res = -1; 457 int res = -1;
458 PyObject *key, *value, *fields; 458 PyObject *key, *value, *fields;
459 fields = _PyObject_GetAttrId((PyObject*)Py_TYPE(self), &PyId__fields); 459 fields = _PyObject_GetAttrId((PyObject*)Py_TYPE(self), &PyId__fields);
460 if (!fields) 460 if (!fields)
504 /* Pickling support */ 504 /* Pickling support */
505 static PyObject * 505 static PyObject *
506 ast_type_reduce(PyObject *self, PyObject *unused) 506 ast_type_reduce(PyObject *self, PyObject *unused)
507 { 507 {
508 PyObject *res; 508 PyObject *res;
509 _Py_identifier(__dict__); 509 _Py_IDENTIFIER(__dict__);
510 PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__); 510 PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__);
511 if (dict == NULL) { 511 if (dict == NULL) {
512 if (PyErr_ExceptionMatches(PyExc_AttributeError)) 512 if (PyErr_ExceptionMatches(PyExc_AttributeError))
513 PyErr_Clear(); 513 PyErr_Clear();
514 else 514 else