comparison Python/Python-ast.c @ 75542:3877bf2e3235

give the AST class a __dict__
author Benjamin Peterson <benjamin@python.org>
date Mon, 12 Mar 2012 09:46:44 -0700
parents e1177b9167ce
children 6bee4eea1efa
comparison
equal deleted inserted replaced
75541:8a5742b7a14d 75542:3877bf2e3235
1 /* File automatically generated by Parser/asdl_c.py. */ 1 /* File automatically generated by Parser/asdl_c.py. */
2
3 #include <stddef.h>
2 4
3 #include "Python.h" 5 #include "Python.h"
4 #include "Python-ast.h" 6 #include "Python-ast.h"
5 7
6 static PyTypeObject AST_type; 8 static PyTypeObject AST_type;
451 "context_expr", 453 "context_expr",
452 "optional_vars", 454 "optional_vars",
453 }; 455 };
454 456
455 457
458 typedef struct {
459 PyObject_HEAD;
460 PyObject *dict;
461 } AST_object;
462
456 static int 463 static int
457 ast_type_init(PyObject *self, PyObject *args, PyObject *kw) 464 ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
458 { 465 {
459 _Py_IDENTIFIER(_fields); 466 _Py_IDENTIFIER(_fields);
460 Py_ssize_t i, numfields = 0; 467 Py_ssize_t i, numfields = 0;
529 static PyMethodDef ast_type_methods[] = { 536 static PyMethodDef ast_type_methods[] = {
530 {"__reduce__", ast_type_reduce, METH_NOARGS, NULL}, 537 {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
531 {NULL} 538 {NULL}
532 }; 539 };
533 540
541 static PyGetSetDef ast_type_getsets[] = {
542 {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
543 {NULL}
544 };
545
534 static PyTypeObject AST_type = { 546 static PyTypeObject AST_type = {
535 PyVarObject_HEAD_INIT(&PyType_Type, 0) 547 PyVarObject_HEAD_INIT(&PyType_Type, 0)
536 "_ast.AST", 548 "_ast.AST",
537 sizeof(PyObject), 549 sizeof(AST_object),
538 0, 550 0,
539 0, /* tp_dealloc */ 551 0, /* tp_dealloc */
540 0, /* tp_print */ 552 0, /* tp_print */
541 0, /* tp_getattr */ 553 0, /* tp_getattr */
542 0, /* tp_setattr */ 554 0, /* tp_setattr */
559 0, /* tp_weaklistoffset */ 571 0, /* tp_weaklistoffset */
560 0, /* tp_iter */ 572 0, /* tp_iter */
561 0, /* tp_iternext */ 573 0, /* tp_iternext */
562 ast_type_methods, /* tp_methods */ 574 ast_type_methods, /* tp_methods */
563 0, /* tp_members */ 575 0, /* tp_members */
564 0, /* tp_getset */ 576 ast_type_getsets, /* tp_getset */
565 0, /* tp_base */ 577 0, /* tp_base */
566 0, /* tp_dict */ 578 0, /* tp_dict */
567 0, /* tp_descr_get */ 579 0, /* tp_descr_get */
568 0, /* tp_descr_set */ 580 0, /* tp_descr_set */
569 0, /* tp_dictoffset */ 581 offsetof(AST_object, dict),/* tp_dictoffset */
570 (initproc)ast_type_init, /* tp_init */ 582 (initproc)ast_type_init, /* tp_init */
571 PyType_GenericAlloc, /* tp_alloc */ 583 PyType_GenericAlloc, /* tp_alloc */
572 PyType_GenericNew, /* tp_new */ 584 PyType_GenericNew, /* tp_new */
573 PyObject_Del, /* tp_free */ 585 PyObject_Del, /* tp_free */
574 }; 586 };