]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/python/python-type.c
* sparc64-nat.c (sparc64_gregset_supplies_p): Add GDBARCH parameter.
[thirdparty/binutils-gdb.git] / gdb / python / python-type.c
CommitLineData
2c74e833
TT
1/* Python interface to types.
2
3 Copyright (C) 2008, 2009 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20#include "defs.h"
21#include "value.h"
22#include "exceptions.h"
23#include "python-internal.h"
24#include "charset.h"
25#include "gdbtypes.h"
26#include "cp-support.h"
27#include "demangle.h"
28#include "objfiles.h"
29
30typedef struct pyty_type_object
31{
32 PyObject_HEAD
33 struct type *type;
34
35 /* If a Type object is associated with an objfile, it is kept on a
36 doubly-linked list, rooted in the objfile. This lets us copy the
37 underlying struct type when the objfile is deleted. */
38 struct pyty_type_object *prev;
39 struct pyty_type_object *next;
40} type_object;
41
42static PyTypeObject type_object_type;
43
44/* A Field object. */
45typedef struct pyty_field_object
46{
47 PyObject_HEAD
48
49 /* Dictionary holding our attributes. */
50 PyObject *dict;
51} field_object;
52
53static PyTypeObject field_object_type;
54
55/* This is used to initialize various gdb.TYPE_ constants. */
56struct pyty_code
57{
58 /* The code. */
59 enum type_code code;
60 /* The name. */
61 const char *name;
62};
63
64#define ENTRY(X) { X, #X }
65
66static struct pyty_code pyty_codes[] =
67{
68 ENTRY (TYPE_CODE_PTR),
69 ENTRY (TYPE_CODE_ARRAY),
70 ENTRY (TYPE_CODE_STRUCT),
71 ENTRY (TYPE_CODE_UNION),
72 ENTRY (TYPE_CODE_ENUM),
73 ENTRY (TYPE_CODE_FLAGS),
74 ENTRY (TYPE_CODE_FUNC),
75 ENTRY (TYPE_CODE_INT),
76 ENTRY (TYPE_CODE_FLT),
77 ENTRY (TYPE_CODE_VOID),
78 ENTRY (TYPE_CODE_SET),
79 ENTRY (TYPE_CODE_RANGE),
80 ENTRY (TYPE_CODE_STRING),
81 ENTRY (TYPE_CODE_BITSTRING),
82 ENTRY (TYPE_CODE_ERROR),
83 ENTRY (TYPE_CODE_METHOD),
84 ENTRY (TYPE_CODE_METHODPTR),
85 ENTRY (TYPE_CODE_MEMBERPTR),
86 ENTRY (TYPE_CODE_REF),
87 ENTRY (TYPE_CODE_CHAR),
88 ENTRY (TYPE_CODE_BOOL),
89 ENTRY (TYPE_CODE_COMPLEX),
90 ENTRY (TYPE_CODE_TYPEDEF),
91 ENTRY (TYPE_CODE_NAMESPACE),
92 ENTRY (TYPE_CODE_DECFLOAT),
93 ENTRY (TYPE_CODE_INTERNAL_FUNCTION),
94 { TYPE_CODE_UNDEF, NULL }
95};
96
97\f
98
99static void
100field_dealloc (PyObject *obj)
101{
102 field_object *f = (field_object *) obj;
103 Py_XDECREF (f->dict);
104 f->ob_type->tp_free (obj);
105}
106
107static PyObject *
108field_new (void)
109{
110 field_object *result = PyObject_New (field_object, &field_object_type);
111 if (result)
112 {
113 result->dict = PyDict_New ();
114 if (!result->dict)
115 {
116 Py_DECREF (result);
117 result = NULL;
118 }
119 }
120 return (PyObject *) result;
121}
122
123\f
124
125/* Return the code for this type. */
126static PyObject *
127typy_get_code (PyObject *self, void *closure)
128{
129 struct type *type = ((type_object *) self)->type;
130 return PyInt_FromLong (TYPE_CODE (type));
131}
132
133/* Helper function for typy_fields which converts a single field to a
134 dictionary. Returns NULL on error. */
135static PyObject *
136convert_field (struct type *type, int field)
137{
138 PyObject *result = field_new ();
139 PyObject *arg;
140
141 if (!result)
142 return NULL;
143
144 if (!field_is_static (&TYPE_FIELD (type, field)))
145 {
146 arg = PyLong_FromLong (TYPE_FIELD_BITPOS (type, field));
147 if (!arg)
148 goto fail;
149
150 if (PyObject_SetAttrString (result, "bitpos", arg) < 0)
151 goto failarg;
152 }
153
154 if (TYPE_FIELD_NAME (type, field))
155 arg = PyString_FromString (TYPE_FIELD_NAME (type, field));
156 else
157 {
158 arg = Py_None;
159 Py_INCREF (arg);
160 }
161 if (!arg)
162 goto fail;
163 if (PyObject_SetAttrString (result, "name", arg) < 0)
164 goto failarg;
165
166 arg = TYPE_FIELD_ARTIFICIAL (type, field) ? Py_True : Py_False;
167 Py_INCREF (arg);
168 if (PyObject_SetAttrString (result, "artificial", arg) < 0)
169 goto failarg;
170
171 arg = PyLong_FromLong (TYPE_FIELD_BITSIZE (type, field));
172 if (!arg)
173 goto fail;
174 if (PyObject_SetAttrString (result, "bitsize", arg) < 0)
175 goto failarg;
176
177 /* A field can have a NULL type in some situations. */
178 if (TYPE_FIELD_TYPE (type, field) == NULL)
179 {
180 arg = Py_None;
181 Py_INCREF (arg);
182 }
183 else
184 arg = type_to_type_object (TYPE_FIELD_TYPE (type, field));
185 if (!arg)
186 goto fail;
187 if (PyObject_SetAttrString (result, "type", arg) < 0)
188 goto failarg;
189
190 return result;
191
192 failarg:
193 Py_DECREF (arg);
194 fail:
195 Py_DECREF (result);
196 return NULL;
197}
198
199/* Return a sequence of all fields. Each field is a dictionary with
200 some pre-defined keys. */
201static PyObject *
202typy_fields (PyObject *self, PyObject *args)
203{
204 PyObject *result;
205 int i;
206 struct type *type = ((type_object *) self)->type;
207
208 /* We would like to make a tuple here, make fields immutable, and
209 then memoize the result (and perhaps make Field.type() lazy).
210 However, that can lead to cycles. */
211 result = PyList_New (0);
212
213 for (i = 0; i < TYPE_NFIELDS (type); ++i)
214 {
215 PyObject *dict = convert_field (type, i);
216 if (!dict)
217 {
218 Py_DECREF (result);
219 return NULL;
220 }
221 if (PyList_Append (result, dict))
222 {
223 Py_DECREF (dict);
224 Py_DECREF (result);
225 return NULL;
226 }
227 }
228
229 return result;
230}
231
232/* Return the type's tag, or None. */
233static PyObject *
234typy_get_tag (PyObject *self, void *closure)
235{
236 struct type *type = ((type_object *) self)->type;
237 if (!TYPE_TAG_NAME (type))
238 Py_RETURN_NONE;
239 return PyString_FromString (TYPE_TAG_NAME (type));
240}
241
242/* Return the type, stripped of typedefs. */
243static PyObject *
244typy_strip_typedefs (PyObject *self, PyObject *args)
245{
246 struct type *type = ((type_object *) self)->type;
247
248 return type_to_type_object (check_typedef (type));
249}
250
251/* Return a Type object which represents a pointer to SELF. */
252static PyObject *
253typy_pointer (PyObject *self, PyObject *args)
254{
255 struct type *type = ((type_object *) self)->type;
256 volatile struct gdb_exception except;
257
258 TRY_CATCH (except, RETURN_MASK_ALL)
259 {
260 type = lookup_pointer_type (type);
261 }
262 GDB_PY_HANDLE_EXCEPTION (except);
263
264 return type_to_type_object (type);
265}
266
267/* Return a Type object which represents a reference to SELF. */
268static PyObject *
269typy_reference (PyObject *self, PyObject *args)
270{
271 struct type *type = ((type_object *) self)->type;
272 volatile struct gdb_exception except;
273
274 TRY_CATCH (except, RETURN_MASK_ALL)
275 {
276 type = lookup_reference_type (type);
277 }
278 GDB_PY_HANDLE_EXCEPTION (except);
279
280 return type_to_type_object (type);
281}
282
283/* Return a Type object which represents the target type of SELF. */
284static PyObject *
285typy_target (PyObject *self, PyObject *args)
286{
287 struct type *type = ((type_object *) self)->type;
288
289 if (!TYPE_TARGET_TYPE (type))
290 {
291 PyErr_SetString (PyExc_RuntimeError, "type does not have a target");
292 return NULL;
293 }
294
295 return type_to_type_object (TYPE_TARGET_TYPE (type));
296}
297
298/* Return a const-qualified type variant. */
299static PyObject *
300typy_const (PyObject *self, PyObject *args)
301{
302 struct type *type = ((type_object *) self)->type;
303 volatile struct gdb_exception except;
304
305 TRY_CATCH (except, RETURN_MASK_ALL)
306 {
307 type = make_cv_type (1, 0, type, NULL);
308 }
309 GDB_PY_HANDLE_EXCEPTION (except);
310
311 return type_to_type_object (type);
312}
313
314/* Return a volatile-qualified type variant. */
315static PyObject *
316typy_volatile (PyObject *self, PyObject *args)
317{
318 struct type *type = ((type_object *) self)->type;
319 volatile struct gdb_exception except;
320
321 TRY_CATCH (except, RETURN_MASK_ALL)
322 {
323 type = make_cv_type (0, 1, type, NULL);
324 }
325 GDB_PY_HANDLE_EXCEPTION (except);
326
327 return type_to_type_object (type);
328}
329
330/* Return an unqualified type variant. */
331static PyObject *
332typy_unqualified (PyObject *self, PyObject *args)
333{
334 struct type *type = ((type_object *) self)->type;
335 volatile struct gdb_exception except;
336
337 TRY_CATCH (except, RETURN_MASK_ALL)
338 {
339 type = make_cv_type (0, 0, type, NULL);
340 }
341 GDB_PY_HANDLE_EXCEPTION (except);
342
343 return type_to_type_object (type);
344}
345
346/* Return the size of the type represented by SELF, in bytes. */
347static PyObject *
348typy_get_sizeof (PyObject *self, void *closure)
349{
350 struct type *type = ((type_object *) self)->type;
351 volatile struct gdb_exception except;
352
353 TRY_CATCH (except, RETURN_MASK_ALL)
354 {
355 check_typedef (type);
356 }
357 /* Ignore exceptions. */
358
359 return PyLong_FromLong (TYPE_LENGTH (type));
360}
361
362static struct type *
363typy_lookup_typename (char *type_name)
364{
365 struct type *type = NULL;
366 volatile struct gdb_exception except;
367 TRY_CATCH (except, RETURN_MASK_ALL)
368 {
369 if (!strncmp (type_name, "struct ", 7))
370 type = lookup_struct (type_name + 7, NULL);
371 else if (!strncmp (type_name, "union ", 6))
372 type = lookup_union (type_name + 6, NULL);
373 else if (!strncmp (type_name, "enum ", 5))
374 type = lookup_enum (type_name + 5, NULL);
375 else
376 type = lookup_typename (type_name, NULL, 0);
377 }
378 if (except.reason < 0)
379 {
380 PyErr_Format (except.reason == RETURN_QUIT
381 ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
382 "%s", except.message);
383 return NULL;
384 }
385
386 return type;
387}
388
389static struct type *
390typy_lookup_type (struct demangle_component *demangled)
391{
392 struct type *type;
393 char *type_name;
394 enum demangle_component_type demangled_type;
395
396 /* Save the type: typy_lookup_type() may (indirectly) overwrite
397 memory pointed by demangled. */
398 demangled_type = demangled->type;
399
400 if (demangled_type == DEMANGLE_COMPONENT_POINTER
401 || demangled_type == DEMANGLE_COMPONENT_REFERENCE
402 || demangled_type == DEMANGLE_COMPONENT_CONST
403 || demangled_type == DEMANGLE_COMPONENT_VOLATILE)
404 {
405 type = typy_lookup_type (demangled->u.s_binary.left);
406 if (! type)
407 return NULL;
408
409 switch (demangled_type)
410 {
411 case DEMANGLE_COMPONENT_REFERENCE:
412 return lookup_reference_type (type);
413 case DEMANGLE_COMPONENT_POINTER:
414 return lookup_pointer_type (type);
415 case DEMANGLE_COMPONENT_CONST:
416 return make_cv_type (1, 0, type, NULL);
417 case DEMANGLE_COMPONENT_VOLATILE:
418 return make_cv_type (0, 1, type, NULL);
419 }
420 }
421
422 type_name = cp_comp_to_string (demangled, 10);
423 type = typy_lookup_typename (type_name);
424 xfree (type_name);
425
426 return type;
427}
428
429static PyObject *
430typy_template_argument (PyObject *self, PyObject *args)
431{
432 int i, argno, n_pointers;
433 struct type *type = ((type_object *) self)->type;
434 struct demangle_component *demangled;
435 const char *err;
436 struct type *argtype;
437
438 if (! PyArg_ParseTuple (args, "i", &argno))
439 return NULL;
440
441 type = check_typedef (type);
442 if (TYPE_CODE (type) == TYPE_CODE_REF)
443 type = check_typedef (TYPE_TARGET_TYPE (type));
444
445 if (TYPE_NAME (type) == NULL)
446 {
447 PyErr_SetString (PyExc_RuntimeError, "null type name");
448 return NULL;
449 }
450
451 /* Note -- this is not thread-safe. */
452 demangled = cp_demangled_name_to_comp (TYPE_NAME (type), &err);
453 if (! demangled)
454 {
455 PyErr_SetString (PyExc_RuntimeError, err);
456 return NULL;
457 }
458
459 /* Strip off component names. */
460 while (demangled->type == DEMANGLE_COMPONENT_QUAL_NAME
461 || demangled->type == DEMANGLE_COMPONENT_LOCAL_NAME)
462 demangled = demangled->u.s_binary.right;
463
464 if (demangled->type != DEMANGLE_COMPONENT_TEMPLATE)
465 {
466 PyErr_SetString (PyExc_RuntimeError, "type is not a template");
467 return NULL;
468 }
469
470 /* Skip from the template to the arguments. */
471 demangled = demangled->u.s_binary.right;
472
473 for (i = 0; demangled && i < argno; ++i)
474 demangled = demangled->u.s_binary.right;
475
476 if (! demangled)
477 {
478 PyErr_Format (PyExc_RuntimeError, "no argument %d in template",
479 argno);
480 return NULL;
481 }
482
483 argtype = typy_lookup_type (demangled->u.s_binary.left);
484 if (! argtype)
485 return NULL;
486
487 return type_to_type_object (argtype);
488}
489
490static PyObject *
491typy_str (PyObject *self)
492{
493 volatile struct gdb_exception except;
494 char *thetype = NULL;
495 PyObject *result;
496
497 TRY_CATCH (except, RETURN_MASK_ALL)
498 {
499 struct cleanup *old_chain;
500 struct ui_file *stb;
501 long length;
502
503 stb = mem_fileopen ();
504 old_chain = make_cleanup_ui_file_delete (stb);
505
506 type_print (type_object_to_type (self), "", stb, -1);
507
508 thetype = ui_file_xstrdup (stb, &length);
509 do_cleanups (old_chain);
510 }
511 if (except.reason < 0)
512 {
513 xfree (thetype);
514 GDB_PY_HANDLE_EXCEPTION (except);
515 }
516
517 result = PyUnicode_Decode (thetype, strlen (thetype), host_charset (), NULL);
518 xfree (thetype);
519
520 return result;
521}
522
523\f
524
525static const struct objfile_data *typy_objfile_data_key;
526
527static void
528clean_up_objfile_types (struct objfile *objfile, void *datum)
529{
530 type_object *obj = datum;
531 htab_t copied_types;
532 struct cleanup *cleanup;
533 PyGILState_STATE state;
534
535 /* This prevents another thread from freeing the objects we're
536 operating on. */
537 state = PyGILState_Ensure ();
538 cleanup = make_cleanup_py_restore_gil (&state);
539
540 copied_types = create_copied_types_hash (objfile);
541
542 while (obj)
543 {
544 type_object *next = obj->next;
545
546 htab_empty (copied_types);
547
548 obj->type = copy_type_recursive (objfile, obj->type, copied_types);
549
550 obj->next = NULL;
551 obj->prev = NULL;
552
553 obj = next;
554 }
555
556 htab_delete (copied_types);
557
558 do_cleanups (cleanup);
559}
560
561static void
562set_type (type_object *obj, struct type *type)
563{
564 obj->type = type;
565 obj->prev = NULL;
566 if (type && TYPE_OBJFILE (type))
567 {
568 struct objfile *objfile = TYPE_OBJFILE (type);
569
570 obj->next = objfile_data (objfile, typy_objfile_data_key);
571 if (obj->next)
572 obj->next->prev = obj;
573 set_objfile_data (objfile, typy_objfile_data_key, obj);
574 }
575 else
576 obj->next = NULL;
577}
578
579static void
580typy_dealloc (PyObject *obj)
581{
582 type_object *type = (type_object *) obj;
583
584 if (type->prev)
585 type->prev->next = type->next;
586 else if (type->type && TYPE_OBJFILE (type->type))
587 {
588 /* Must reset head of list. */
589 struct objfile *objfile = TYPE_OBJFILE (type->type);
590 if (objfile)
591 set_objfile_data (objfile, typy_objfile_data_key, type->next);
592 }
593 if (type->next)
594 type->next->prev = type->prev;
595
596 type->ob_type->tp_free (type);
597}
598
599/* Create a new Type referring to TYPE. */
600PyObject *
601type_to_type_object (struct type *type)
602{
603 type_object *type_obj;
604
605 type_obj = PyObject_New (type_object, &type_object_type);
606 if (type_obj)
607 set_type (type_obj, type);
608
609 return (PyObject *) type_obj;
610}
611
612struct type *
613type_object_to_type (PyObject *obj)
614{
615 if (! PyObject_TypeCheck (obj, &type_object_type))
616 return NULL;
617 return ((type_object *) obj)->type;
618}
619
620\f
621
622/* Implementation of gdb.lookup_type. */
623PyObject *
624gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
625{
626 static char *keywords[] = { "name", NULL };
627 char *type_name = NULL;
628 struct type *type = NULL;
629
630 if (! PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &type_name))
631 return NULL;
632
633 type = typy_lookup_typename (type_name);
634 if (! type)
635 return NULL;
636
637 return (PyObject *) type_to_type_object (type);
638}
639
640void
641gdbpy_initialize_types (void)
642{
643 int i;
644
645 typy_objfile_data_key
646 = register_objfile_data_with_cleanup (clean_up_objfile_types);
647
648 if (PyType_Ready (&type_object_type) < 0)
649 return;
650 if (PyType_Ready (&field_object_type) < 0)
651 return;
652
653 for (i = 0; pyty_codes[i].name; ++i)
654 {
655 if (PyModule_AddIntConstant (gdb_module,
656 /* Cast needed for Python 2.4. */
657 (char *) pyty_codes[i].name,
658 pyty_codes[i].code) < 0)
659 return;
660 }
661
662 Py_INCREF (&type_object_type);
663 PyModule_AddObject (gdb_module, "Type", (PyObject *) &type_object_type);
664
665 Py_INCREF (&field_object_type);
666 PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type);
667}
668
669\f
670
671static PyGetSetDef type_object_getset[] =
672{
673 { "code", typy_get_code, NULL,
674 "The code for this type.", NULL },
675 { "sizeof", typy_get_sizeof, NULL,
676 "The size of this type, in bytes.", NULL },
677 { "tag", typy_get_tag, NULL,
678 "The tag name for this type, or None.", NULL },
679 { NULL }
680};
681
682static PyMethodDef type_object_methods[] =
683{
684 { "const", typy_const, METH_NOARGS,
685 "const () -> Type\n\
686Return a const variant of this type." },
687 { "fields", typy_fields, METH_NOARGS,
688 "field () -> list\n\
689Return a sequence holding all the fields of this type.\n\
690Each field is a dictionary." },
691 { "pointer", typy_pointer, METH_NOARGS,
692 "pointer () -> Type\n\
693Return a type of pointer to this type." },
694 { "reference", typy_reference, METH_NOARGS,
695 "reference () -> Type\n\
696Return a type of reference to this type." },
697 { "strip_typedefs", typy_strip_typedefs, METH_NOARGS,
698 "strip_typedefs () -> Type\n\
699Return a type formed by stripping this type of all typedefs."},
700 { "target", typy_target, METH_NOARGS,
701 "target () -> Type\n\
702Return the target type of this type." },
703 { "template_argument", typy_template_argument, METH_VARARGS,
704 "template_argument (arg) -> Type\n\
705Return the type of a template argument." },
706 { "unqualified", typy_unqualified, METH_NOARGS,
707 "unqualified () -> Type\n\
708Return a variant of this type without const or volatile attributes." },
709 { "volatile", typy_volatile, METH_NOARGS,
710 "volatile () -> Type\n\
711Return a volatile variant of this type" },
712 { NULL }
713};
714
715static PyTypeObject type_object_type =
716{
717 PyObject_HEAD_INIT (NULL)
718 0, /*ob_size*/
719 "gdb.Type", /*tp_name*/
720 sizeof (type_object), /*tp_basicsize*/
721 0, /*tp_itemsize*/
722 typy_dealloc, /*tp_dealloc*/
723 0, /*tp_print*/
724 0, /*tp_getattr*/
725 0, /*tp_setattr*/
726 0, /*tp_compare*/
727 0, /*tp_repr*/
728 0, /*tp_as_number*/
729 0, /*tp_as_sequence*/
730 0, /*tp_as_mapping*/
731 0, /*tp_hash */
732 0, /*tp_call*/
733 typy_str, /*tp_str*/
734 0, /*tp_getattro*/
735 0, /*tp_setattro*/
736 0, /*tp_as_buffer*/
737 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/
738 "GDB type object", /* tp_doc */
739 0, /* tp_traverse */
740 0, /* tp_clear */
741 0, /* tp_richcompare */
742 0, /* tp_weaklistoffset */
743 0, /* tp_iter */
744 0, /* tp_iternext */
745 type_object_methods, /* tp_methods */
746 0, /* tp_members */
747 type_object_getset, /* tp_getset */
748 0, /* tp_base */
749 0, /* tp_dict */
750 0, /* tp_descr_get */
751 0, /* tp_descr_set */
752 0, /* tp_dictoffset */
753 0, /* tp_init */
754 0, /* tp_alloc */
755 0, /* tp_new */
756};
757
758static PyTypeObject field_object_type =
759{
760 PyObject_HEAD_INIT (NULL)
761 0, /*ob_size*/
762 "gdb.Field", /*tp_name*/
763 sizeof (field_object), /*tp_basicsize*/
764 0, /*tp_itemsize*/
765 field_dealloc, /*tp_dealloc*/
766 0, /*tp_print*/
767 0, /*tp_getattr*/
768 0, /*tp_setattr*/
769 0, /*tp_compare*/
770 0, /*tp_repr*/
771 0, /*tp_as_number*/
772 0, /*tp_as_sequence*/
773 0, /*tp_as_mapping*/
774 0, /*tp_hash */
775 0, /*tp_call*/
776 0, /*tp_str*/
777 0, /*tp_getattro*/
778 0, /*tp_setattro*/
779 0, /*tp_as_buffer*/
780 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/
781 "GDB field object", /* tp_doc */
782 0, /* tp_traverse */
783 0, /* tp_clear */
784 0, /* tp_richcompare */
785 0, /* tp_weaklistoffset */
786 0, /* tp_iter */
787 0, /* tp_iternext */
788 0, /* tp_methods */
789 0, /* tp_members */
790 0, /* tp_getset */
791 0, /* tp_base */
792 0, /* tp_dict */
793 0, /* tp_descr_get */
794 0, /* tp_descr_set */
795 offsetof (field_object, dict), /* tp_dictoffset */
796 0, /* tp_init */
797 0, /* tp_alloc */
798 0, /* tp_new */
799};