1 /* Python interface to types.
3 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include "exceptions.h"
23 #include "python-internal.h"
26 #include "cp-support.h"
31 typedef struct pyty_type_object
36 /* If a Type object is associated with an objfile, it is kept on a
37 doubly-linked list, rooted in the objfile. This lets us copy the
38 underlying struct type when the objfile is deleted. */
39 struct pyty_type_object
*prev
;
40 struct pyty_type_object
*next
;
43 static PyTypeObject type_object_type
;
46 typedef struct pyty_field_object
50 /* Dictionary holding our attributes. */
54 static PyTypeObject field_object_type
;
56 /* This is used to initialize various gdb.TYPE_ constants. */
65 #define ENTRY(X) { X, #X }
67 static struct pyty_code pyty_codes
[] =
69 ENTRY (TYPE_CODE_PTR
),
70 ENTRY (TYPE_CODE_ARRAY
),
71 ENTRY (TYPE_CODE_STRUCT
),
72 ENTRY (TYPE_CODE_UNION
),
73 ENTRY (TYPE_CODE_ENUM
),
74 ENTRY (TYPE_CODE_FLAGS
),
75 ENTRY (TYPE_CODE_FUNC
),
76 ENTRY (TYPE_CODE_INT
),
77 ENTRY (TYPE_CODE_FLT
),
78 ENTRY (TYPE_CODE_VOID
),
79 ENTRY (TYPE_CODE_SET
),
80 ENTRY (TYPE_CODE_RANGE
),
81 ENTRY (TYPE_CODE_STRING
),
82 ENTRY (TYPE_CODE_BITSTRING
),
83 ENTRY (TYPE_CODE_ERROR
),
84 ENTRY (TYPE_CODE_METHOD
),
85 ENTRY (TYPE_CODE_METHODPTR
),
86 ENTRY (TYPE_CODE_MEMBERPTR
),
87 ENTRY (TYPE_CODE_REF
),
88 ENTRY (TYPE_CODE_CHAR
),
89 ENTRY (TYPE_CODE_BOOL
),
90 ENTRY (TYPE_CODE_COMPLEX
),
91 ENTRY (TYPE_CODE_TYPEDEF
),
92 ENTRY (TYPE_CODE_NAMESPACE
),
93 ENTRY (TYPE_CODE_DECFLOAT
),
94 ENTRY (TYPE_CODE_INTERNAL_FUNCTION
),
95 { TYPE_CODE_UNDEF
, NULL
}
101 field_dealloc (PyObject
*obj
)
103 field_object
*f
= (field_object
*) obj
;
105 Py_XDECREF (f
->dict
);
106 f
->ob_type
->tp_free (obj
);
112 field_object
*result
= PyObject_New (field_object
, &field_object_type
);
116 result
->dict
= PyDict_New ();
123 return (PyObject
*) result
;
128 /* Return the code for this type. */
130 typy_get_code (PyObject
*self
, void *closure
)
132 struct type
*type
= ((type_object
*) self
)->type
;
134 return PyInt_FromLong (TYPE_CODE (type
));
137 /* Helper function for typy_fields which converts a single field to a
138 dictionary. Returns NULL on error. */
140 convert_field (struct type
*type
, int field
)
142 PyObject
*result
= field_new ();
148 if (!field_is_static (&TYPE_FIELD (type
, field
)))
150 arg
= PyLong_FromLong (TYPE_FIELD_BITPOS (type
, field
));
154 if (PyObject_SetAttrString (result
, "bitpos", arg
) < 0)
158 if (TYPE_FIELD_NAME (type
, field
))
159 arg
= PyString_FromString (TYPE_FIELD_NAME (type
, field
));
167 if (PyObject_SetAttrString (result
, "name", arg
) < 0)
170 arg
= TYPE_FIELD_ARTIFICIAL (type
, field
) ? Py_True
: Py_False
;
172 if (PyObject_SetAttrString (result
, "artificial", arg
) < 0)
175 if (TYPE_CODE (type
) == TYPE_CODE_CLASS
)
176 arg
= field
< TYPE_N_BASECLASSES (type
) ? Py_True
: Py_False
;
180 if (PyObject_SetAttrString (result
, "is_base_class", arg
) < 0)
183 arg
= PyLong_FromLong (TYPE_FIELD_BITSIZE (type
, field
));
186 if (PyObject_SetAttrString (result
, "bitsize", arg
) < 0)
189 /* A field can have a NULL type in some situations. */
190 if (TYPE_FIELD_TYPE (type
, field
) == NULL
)
196 arg
= type_to_type_object (TYPE_FIELD_TYPE (type
, field
));
199 if (PyObject_SetAttrString (result
, "type", arg
) < 0)
211 /* Return a sequence of all fields. Each field is a dictionary with
212 some pre-defined keys. */
214 typy_fields (PyObject
*self
, PyObject
*args
)
218 struct type
*type
= ((type_object
*) self
)->type
;
219 volatile struct gdb_exception except
;
221 TRY_CATCH (except
, RETURN_MASK_ALL
)
223 CHECK_TYPEDEF (type
);
225 GDB_PY_HANDLE_EXCEPTION (except
);
227 /* We would like to make a tuple here, make fields immutable, and
228 then memoize the result (and perhaps make Field.type() lazy).
229 However, that can lead to cycles. */
230 result
= PyList_New (0);
232 for (i
= 0; i
< TYPE_NFIELDS (type
); ++i
)
234 PyObject
*dict
= convert_field (type
, i
);
241 if (PyList_Append (result
, dict
))
252 /* Return the type's tag, or None. */
254 typy_get_tag (PyObject
*self
, void *closure
)
256 struct type
*type
= ((type_object
*) self
)->type
;
258 if (!TYPE_TAG_NAME (type
))
260 return PyString_FromString (TYPE_TAG_NAME (type
));
263 /* Return the type, stripped of typedefs. */
265 typy_strip_typedefs (PyObject
*self
, PyObject
*args
)
267 struct type
*type
= ((type_object
*) self
)->type
;
269 return type_to_type_object (check_typedef (type
));
272 /* Return an array type. */
275 typy_array (PyObject
*self
, PyObject
*args
)
278 PyObject
*n2_obj
= NULL
;
279 struct type
*array
= NULL
;
280 struct type
*type
= ((type_object
*) self
)->type
;
281 volatile struct gdb_exception except
;
283 if (! PyArg_ParseTuple (args
, "i|O", &n1
, &n2_obj
))
288 if (!PyInt_Check (n2_obj
))
290 PyErr_SetString (PyExc_RuntimeError
,
291 _("Array bound must be an integer"));
294 n2
= (int) PyInt_AsLong (n2_obj
);
295 if (PyErr_Occurred ())
306 PyErr_SetString (PyExc_ValueError
,
307 _("Array length must not be negative"));
311 TRY_CATCH (except
, RETURN_MASK_ALL
)
313 array
= lookup_array_range_type (type
, n1
, n2
);
315 GDB_PY_HANDLE_EXCEPTION (except
);
317 return type_to_type_object (array
);
320 /* Return a Type object which represents a pointer to SELF. */
322 typy_pointer (PyObject
*self
, PyObject
*args
)
324 struct type
*type
= ((type_object
*) self
)->type
;
325 volatile struct gdb_exception except
;
327 TRY_CATCH (except
, RETURN_MASK_ALL
)
329 type
= lookup_pointer_type (type
);
331 GDB_PY_HANDLE_EXCEPTION (except
);
333 return type_to_type_object (type
);
336 /* Return the range of a type represented by SELF. The return type is
337 a tuple. The first element of the tuple contains the low bound,
338 while the second element of the tuple contains the high bound. */
340 typy_range (PyObject
*self
, PyObject
*args
)
342 struct type
*type
= ((type_object
*) self
)->type
;
344 PyObject
*low_bound
= NULL
, *high_bound
= NULL
;
345 /* Initialize these to appease GCC warnings. */
346 LONGEST low
= 0, high
= 0;
348 if (TYPE_CODE (type
) != TYPE_CODE_ARRAY
349 && TYPE_CODE (type
) != TYPE_CODE_STRING
350 && TYPE_CODE (type
) != TYPE_CODE_RANGE
)
352 PyErr_SetString (PyExc_RuntimeError
,
353 _("This type does not have a range."));
357 switch (TYPE_CODE (type
))
359 case TYPE_CODE_ARRAY
:
360 case TYPE_CODE_STRING
:
361 low
= TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type
));
362 high
= TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (type
));
364 case TYPE_CODE_RANGE
:
365 low
= TYPE_LOW_BOUND (type
);
366 high
= TYPE_HIGH_BOUND (type
);
370 low_bound
= PyLong_FromLong (low
);
374 high_bound
= PyLong_FromLong (high
);
378 result
= PyTuple_New (2);
382 if (PyTuple_SetItem (result
, 0, low_bound
) != 0)
387 if (PyTuple_SetItem (result
, 1, high_bound
) != 0)
389 Py_DECREF (high_bound
);
396 Py_XDECREF (high_bound
);
397 Py_XDECREF (low_bound
);
401 /* Return a Type object which represents a reference to SELF. */
403 typy_reference (PyObject
*self
, PyObject
*args
)
405 struct type
*type
= ((type_object
*) self
)->type
;
406 volatile struct gdb_exception except
;
408 TRY_CATCH (except
, RETURN_MASK_ALL
)
410 type
= lookup_reference_type (type
);
412 GDB_PY_HANDLE_EXCEPTION (except
);
414 return type_to_type_object (type
);
417 /* Return a Type object which represents the target type of SELF. */
419 typy_target (PyObject
*self
, PyObject
*args
)
421 struct type
*type
= ((type_object
*) self
)->type
;
423 if (!TYPE_TARGET_TYPE (type
))
425 PyErr_SetString (PyExc_RuntimeError
,
426 _("Type does not have a target."));
430 return type_to_type_object (TYPE_TARGET_TYPE (type
));
433 /* Return a const-qualified type variant. */
435 typy_const (PyObject
*self
, PyObject
*args
)
437 struct type
*type
= ((type_object
*) self
)->type
;
438 volatile struct gdb_exception except
;
440 TRY_CATCH (except
, RETURN_MASK_ALL
)
442 type
= make_cv_type (1, 0, type
, NULL
);
444 GDB_PY_HANDLE_EXCEPTION (except
);
446 return type_to_type_object (type
);
449 /* Return a volatile-qualified type variant. */
451 typy_volatile (PyObject
*self
, PyObject
*args
)
453 struct type
*type
= ((type_object
*) self
)->type
;
454 volatile struct gdb_exception except
;
456 TRY_CATCH (except
, RETURN_MASK_ALL
)
458 type
= make_cv_type (0, 1, type
, NULL
);
460 GDB_PY_HANDLE_EXCEPTION (except
);
462 return type_to_type_object (type
);
465 /* Return an unqualified type variant. */
467 typy_unqualified (PyObject
*self
, PyObject
*args
)
469 struct type
*type
= ((type_object
*) self
)->type
;
470 volatile struct gdb_exception except
;
472 TRY_CATCH (except
, RETURN_MASK_ALL
)
474 type
= make_cv_type (0, 0, type
, NULL
);
476 GDB_PY_HANDLE_EXCEPTION (except
);
478 return type_to_type_object (type
);
481 /* Return the size of the type represented by SELF, in bytes. */
483 typy_get_sizeof (PyObject
*self
, void *closure
)
485 struct type
*type
= ((type_object
*) self
)->type
;
486 volatile struct gdb_exception except
;
488 TRY_CATCH (except
, RETURN_MASK_ALL
)
490 check_typedef (type
);
492 /* Ignore exceptions. */
494 return PyLong_FromLong (TYPE_LENGTH (type
));
498 typy_lookup_typename (char *type_name
, struct block
*block
)
500 struct type
*type
= NULL
;
501 volatile struct gdb_exception except
;
503 TRY_CATCH (except
, RETURN_MASK_ALL
)
505 if (!strncmp (type_name
, "struct ", 7))
506 type
= lookup_struct (type_name
+ 7, NULL
);
507 else if (!strncmp (type_name
, "union ", 6))
508 type
= lookup_union (type_name
+ 6, NULL
);
509 else if (!strncmp (type_name
, "enum ", 5))
510 type
= lookup_enum (type_name
+ 5, NULL
);
512 type
= lookup_typename (python_language
, python_gdbarch
,
513 type_name
, block
, 0);
515 if (except
.reason
< 0)
517 PyErr_Format (except
.reason
== RETURN_QUIT
518 ? PyExc_KeyboardInterrupt
: PyExc_RuntimeError
,
519 "%s", except
.message
);
527 typy_lookup_type (struct demangle_component
*demangled
,
532 enum demangle_component_type demangled_type
;
534 /* Save the type: typy_lookup_type() may (indirectly) overwrite
535 memory pointed by demangled. */
536 demangled_type
= demangled
->type
;
538 if (demangled_type
== DEMANGLE_COMPONENT_POINTER
539 || demangled_type
== DEMANGLE_COMPONENT_REFERENCE
540 || demangled_type
== DEMANGLE_COMPONENT_CONST
541 || demangled_type
== DEMANGLE_COMPONENT_VOLATILE
)
543 type
= typy_lookup_type (demangled
->u
.s_binary
.left
, block
);
547 switch (demangled_type
)
549 case DEMANGLE_COMPONENT_REFERENCE
:
550 return lookup_reference_type (type
);
551 case DEMANGLE_COMPONENT_POINTER
:
552 return lookup_pointer_type (type
);
553 case DEMANGLE_COMPONENT_CONST
:
554 return make_cv_type (1, 0, type
, NULL
);
555 case DEMANGLE_COMPONENT_VOLATILE
:
556 return make_cv_type (0, 1, type
, NULL
);
560 type_name
= cp_comp_to_string (demangled
, 10);
561 type
= typy_lookup_typename (type_name
, block
);
567 /* This is a helper function for typy_template_argument that is used
568 when the type does not have template symbols attached. It works by
569 parsing the type name. This happens with compilers, like older
570 versions of GCC, that do not emit DW_TAG_template_*. */
573 typy_legacy_template_argument (struct type
*type
, struct block
*block
,
577 struct demangle_component
*demangled
;
579 struct type
*argtype
;
581 if (TYPE_NAME (type
) == NULL
)
583 PyErr_SetString (PyExc_RuntimeError
, _("Null type name."));
587 /* Note -- this is not thread-safe. */
588 demangled
= cp_demangled_name_to_comp (TYPE_NAME (type
), &err
);
591 PyErr_SetString (PyExc_RuntimeError
, err
);
595 /* Strip off component names. */
596 while (demangled
->type
== DEMANGLE_COMPONENT_QUAL_NAME
597 || demangled
->type
== DEMANGLE_COMPONENT_LOCAL_NAME
)
598 demangled
= demangled
->u
.s_binary
.right
;
600 if (demangled
->type
!= DEMANGLE_COMPONENT_TEMPLATE
)
602 PyErr_SetString (PyExc_RuntimeError
, _("Type is not a template."));
606 /* Skip from the template to the arguments. */
607 demangled
= demangled
->u
.s_binary
.right
;
609 for (i
= 0; demangled
&& i
< argno
; ++i
)
610 demangled
= demangled
->u
.s_binary
.right
;
614 PyErr_Format (PyExc_RuntimeError
, _("No argument %d in template."),
619 argtype
= typy_lookup_type (demangled
->u
.s_binary
.left
, block
);
623 return type_to_type_object (argtype
);
627 typy_template_argument (PyObject
*self
, PyObject
*args
)
630 struct type
*type
= ((type_object
*) self
)->type
;
631 struct block
*block
= NULL
;
632 PyObject
*block_obj
= NULL
;
634 struct value
*val
= NULL
;
635 volatile struct gdb_exception except
;
637 if (! PyArg_ParseTuple (args
, "i|O", &argno
, &block_obj
))
642 block
= block_object_to_block (block_obj
);
645 PyErr_SetString (PyExc_RuntimeError
,
646 _("Second argument must be block."));
651 TRY_CATCH (except
, RETURN_MASK_ALL
)
653 type
= check_typedef (type
);
654 if (TYPE_CODE (type
) == TYPE_CODE_REF
)
655 type
= check_typedef (TYPE_TARGET_TYPE (type
));
657 GDB_PY_HANDLE_EXCEPTION (except
);
659 /* We might not have DW_TAG_template_*, so try to parse the type's
660 name. This is inefficient if we do not have a template type --
661 but that is going to wind up as an error anyhow. */
662 if (! TYPE_N_TEMPLATE_ARGUMENTS (type
))
663 return typy_legacy_template_argument (type
, block
, argno
);
665 if (argno
>= TYPE_N_TEMPLATE_ARGUMENTS (type
))
667 PyErr_Format (PyExc_RuntimeError
, _("No argument %d in template."),
672 sym
= TYPE_TEMPLATE_ARGUMENT (type
, argno
);
673 if (SYMBOL_CLASS (sym
) == LOC_TYPEDEF
)
674 return type_to_type_object (SYMBOL_TYPE (sym
));
675 else if (SYMBOL_CLASS (sym
) == LOC_OPTIMIZED_OUT
)
677 PyErr_Format (PyExc_RuntimeError
,
678 _("Template argument is optimized out"));
682 TRY_CATCH (except
, RETURN_MASK_ALL
)
684 val
= value_of_variable (sym
, block
);
686 GDB_PY_HANDLE_EXCEPTION (except
);
688 return value_to_value_object (val
);
692 typy_str (PyObject
*self
)
694 volatile struct gdb_exception except
;
695 char *thetype
= NULL
;
699 TRY_CATCH (except
, RETURN_MASK_ALL
)
701 struct cleanup
*old_chain
;
704 stb
= mem_fileopen ();
705 old_chain
= make_cleanup_ui_file_delete (stb
);
707 type_print (type_object_to_type (self
), "", stb
, -1);
709 thetype
= ui_file_xstrdup (stb
, &length
);
710 do_cleanups (old_chain
);
712 if (except
.reason
< 0)
715 GDB_PY_HANDLE_EXCEPTION (except
);
718 result
= PyUnicode_Decode (thetype
, length
, host_charset (), NULL
);
726 static const struct objfile_data
*typy_objfile_data_key
;
729 save_objfile_types (struct objfile
*objfile
, void *datum
)
731 type_object
*obj
= datum
;
733 struct cleanup
*cleanup
;
735 /* This prevents another thread from freeing the objects we're
737 cleanup
= ensure_python_env (get_objfile_arch (objfile
), current_language
);
739 copied_types
= create_copied_types_hash (objfile
);
743 type_object
*next
= obj
->next
;
745 htab_empty (copied_types
);
747 obj
->type
= copy_type_recursive (objfile
, obj
->type
, copied_types
);
755 htab_delete (copied_types
);
757 do_cleanups (cleanup
);
761 set_type (type_object
*obj
, struct type
*type
)
765 if (type
&& TYPE_OBJFILE (type
))
767 struct objfile
*objfile
= TYPE_OBJFILE (type
);
769 obj
->next
= objfile_data (objfile
, typy_objfile_data_key
);
771 obj
->next
->prev
= obj
;
772 set_objfile_data (objfile
, typy_objfile_data_key
, obj
);
779 typy_dealloc (PyObject
*obj
)
781 type_object
*type
= (type_object
*) obj
;
784 type
->prev
->next
= type
->next
;
785 else if (type
->type
&& TYPE_OBJFILE (type
->type
))
787 /* Must reset head of list. */
788 struct objfile
*objfile
= TYPE_OBJFILE (type
->type
);
791 set_objfile_data (objfile
, typy_objfile_data_key
, type
->next
);
794 type
->next
->prev
= type
->prev
;
796 type
->ob_type
->tp_free (type
);
799 /* Create a new Type referring to TYPE. */
801 type_to_type_object (struct type
*type
)
803 type_object
*type_obj
;
805 type_obj
= PyObject_New (type_object
, &type_object_type
);
807 set_type (type_obj
, type
);
809 return (PyObject
*) type_obj
;
813 type_object_to_type (PyObject
*obj
)
815 if (! PyObject_TypeCheck (obj
, &type_object_type
))
817 return ((type_object
*) obj
)->type
;
822 /* Implementation of gdb.lookup_type. */
824 gdbpy_lookup_type (PyObject
*self
, PyObject
*args
, PyObject
*kw
)
826 static char *keywords
[] = { "name", "block", NULL
};
827 char *type_name
= NULL
;
828 struct type
*type
= NULL
;
829 PyObject
*block_obj
= NULL
;
830 struct block
*block
= NULL
;
832 if (! PyArg_ParseTupleAndKeywords (args
, kw
, "s|O", keywords
,
833 &type_name
, &block_obj
))
838 block
= block_object_to_block (block_obj
);
841 PyErr_SetString (PyExc_RuntimeError
,
842 _("'block' argument must be a Block."));
847 type
= typy_lookup_typename (type_name
, block
);
851 return (PyObject
*) type_to_type_object (type
);
855 gdbpy_initialize_types (void)
859 typy_objfile_data_key
860 = register_objfile_data_with_cleanup (save_objfile_types
, NULL
);
862 if (PyType_Ready (&type_object_type
) < 0)
864 if (PyType_Ready (&field_object_type
) < 0)
867 for (i
= 0; pyty_codes
[i
].name
; ++i
)
869 if (PyModule_AddIntConstant (gdb_module
,
870 /* Cast needed for Python 2.4. */
871 (char *) pyty_codes
[i
].name
,
872 pyty_codes
[i
].code
) < 0)
876 Py_INCREF (&type_object_type
);
877 PyModule_AddObject (gdb_module
, "Type", (PyObject
*) &type_object_type
);
879 Py_INCREF (&field_object_type
);
880 PyModule_AddObject (gdb_module
, "Field", (PyObject
*) &field_object_type
);
885 static PyGetSetDef type_object_getset
[] =
887 { "code", typy_get_code
, NULL
,
888 "The code for this type.", NULL
},
889 { "sizeof", typy_get_sizeof
, NULL
,
890 "The size of this type, in bytes.", NULL
},
891 { "tag", typy_get_tag
, NULL
,
892 "The tag name for this type, or None.", NULL
},
896 static PyMethodDef type_object_methods
[] =
898 { "array", typy_array
, METH_VARARGS
,
899 "array (N) -> Type\n\
900 Return a type which represents an array of N objects of this type." },
901 { "const", typy_const
, METH_NOARGS
,
903 Return a const variant of this type." },
904 { "fields", typy_fields
, METH_NOARGS
,
906 Return a sequence holding all the fields of this type.\n\
907 Each field is a dictionary." },
908 { "pointer", typy_pointer
, METH_NOARGS
,
909 "pointer () -> Type\n\
910 Return a type of pointer to this type." },
911 { "range", typy_range
, METH_NOARGS
,
912 "range () -> tuple\n\
913 Return a tuple containing the lower and upper range for this type."},
914 { "reference", typy_reference
, METH_NOARGS
,
915 "reference () -> Type\n\
916 Return a type of reference to this type." },
917 { "strip_typedefs", typy_strip_typedefs
, METH_NOARGS
,
918 "strip_typedefs () -> Type\n\
919 Return a type formed by stripping this type of all typedefs."},
920 { "target", typy_target
, METH_NOARGS
,
921 "target () -> Type\n\
922 Return the target type of this type." },
923 { "template_argument", typy_template_argument
, METH_VARARGS
,
924 "template_argument (arg, [block]) -> Type\n\
925 Return the type of a template argument." },
926 { "unqualified", typy_unqualified
, METH_NOARGS
,
927 "unqualified () -> Type\n\
928 Return a variant of this type without const or volatile attributes." },
929 { "volatile", typy_volatile
, METH_NOARGS
,
930 "volatile () -> Type\n\
931 Return a volatile variant of this type" },
935 static PyTypeObject type_object_type
=
937 PyObject_HEAD_INIT (NULL
)
939 "gdb.Type", /*tp_name*/
940 sizeof (type_object
), /*tp_basicsize*/
942 typy_dealloc
, /*tp_dealloc*/
949 0, /*tp_as_sequence*/
957 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_HAVE_ITER
, /*tp_flags*/
958 "GDB type object", /* tp_doc */
961 0, /* tp_richcompare */
962 0, /* tp_weaklistoffset */
965 type_object_methods
, /* tp_methods */
967 type_object_getset
, /* tp_getset */
970 0, /* tp_descr_get */
971 0, /* tp_descr_set */
972 0, /* tp_dictoffset */
978 static PyTypeObject field_object_type
=
980 PyObject_HEAD_INIT (NULL
)
982 "gdb.Field", /*tp_name*/
983 sizeof (field_object
), /*tp_basicsize*/
985 field_dealloc
, /*tp_dealloc*/
992 0, /*tp_as_sequence*/
1000 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_HAVE_ITER
, /*tp_flags*/
1001 "GDB field object", /* tp_doc */
1002 0, /* tp_traverse */
1004 0, /* tp_richcompare */
1005 0, /* tp_weaklistoffset */
1007 0, /* tp_iternext */
1013 0, /* tp_descr_get */
1014 0, /* tp_descr_set */
1015 offsetof (field_object
, dict
), /* tp_dictoffset */