MCPcopy Index your code
hub / github.com/python/cpython / PyTypesVisitor

Class PyTypesVisitor

Parser/asdl_c.py:835–1957  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

833
834
835class PyTypesVisitor(PickleVisitor):
836
837 def visitModule(self, mod):
838 self.emit("""
839
840typedef struct {
841 PyObject_HEAD
842 PyObject *dict;
843} AST_object;
844
845static void
846ast_dealloc(PyObject *op)
847{
848 AST_object *self = (AST_object*)op;
849 /* bpo-31095: UnTrack is needed before calling any callbacks */
850 PyTypeObject *tp = Py_TYPE(self);
851 PyObject_GC_UnTrack(self);
852 Py_CLEAR(self->dict);
853 freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
854 assert(free_func != NULL);
855 free_func(self);
856 Py_DECREF(tp);
857}
858
859static int
860ast_traverse(PyObject *op, visitproc visit, void *arg)
861{
862 AST_object *self = (AST_object*)op;
863 Py_VISIT(Py_TYPE(self));
864 Py_VISIT(self->dict);
865 return 0;
866}
867
868static int
869ast_clear(PyObject *op)
870{
871 AST_object *self = (AST_object*)op;
872 Py_CLEAR(self->dict);
873 return 0;
874}
875
876static int
877ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
878{
879 struct ast_state *state = get_ast_state();
880 if (state == NULL) {
881 return -1;
882 }
883
884 Py_ssize_t i, numfields = 0;
885 int res = -1;
886 PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
887
888 fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
889 if (fields == NULL) {
890 goto cleanup;
891 }
892

Callers 1

write_sourceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…