]> Git Repo - binutils.git/blob - gdb/python/py-param.c
99a57960c059cd754afe6648c055a19c3c986221
[binutils.git] / gdb / python / py-param.c
1 /* GDB parameters implemented in Python
2
3    Copyright (C) 2008-2021 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
21 #include "defs.h"
22 #include "value.h"
23 #include "python-internal.h"
24 #include "charset.h"
25 #include "gdbcmd.h"
26 #include "cli/cli-decode.h"
27 #include "completer.h"
28 #include "language.h"
29 #include "arch-utils.h"
30
31 /* Parameter constants and their values.  */
32 static struct {
33   const char *name;
34   int value;
35 } parm_constants[] =
36 {
37   { "PARAM_BOOLEAN", var_boolean }, /* ARI: var_boolean */
38   { "PARAM_AUTO_BOOLEAN", var_auto_boolean },
39   { "PARAM_UINTEGER", var_uinteger },
40   { "PARAM_INTEGER", var_integer },
41   { "PARAM_STRING", var_string },
42   { "PARAM_STRING_NOESCAPE", var_string_noescape },
43   { "PARAM_OPTIONAL_FILENAME", var_optional_filename },
44   { "PARAM_FILENAME", var_filename },
45   { "PARAM_ZINTEGER", var_zinteger },
46   { "PARAM_ZUINTEGER", var_zuinteger },
47   { "PARAM_ZUINTEGER_UNLIMITED", var_zuinteger_unlimited },
48   { "PARAM_ENUM", var_enum },
49   { NULL, 0 }
50 };
51
52 /* A union that can hold anything described by enum var_types.  */
53 union parmpy_variable
54 {
55   /* Hold a boolean value.  */
56   bool boolval;
57
58   /* Hold an integer value.  */
59   int intval;
60
61   /* Hold an auto_boolean.  */
62   enum auto_boolean autoboolval;
63
64   /* Hold an unsigned integer value, for uinteger.  */
65   unsigned int uintval;
66
67   /* Hold a string, for the various string types.  */
68   char *stringval;
69
70   /* Hold a string, for enums.  */
71   const char *cstringval;
72 };
73
74 /* A GDB parameter.  */
75 struct parmpy_object
76 {
77   PyObject_HEAD
78
79   /* The type of the parameter.  */
80   enum var_types type;
81
82   /* The value of the parameter.  */
83   union parmpy_variable value;
84
85   /* For an enum command, the possible values.  The vector is
86      allocated with xmalloc, as is each element.  It is
87      NULL-terminated.  */
88   const char **enumeration;
89 };
90
91 extern PyTypeObject parmpy_object_type
92     CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("parmpy_object");
93
94 /* Some handy string constants.  */
95 static PyObject *set_doc_cst;
96 static PyObject *show_doc_cst;
97
98 \f
99
100 /* Get an attribute.  */
101 static PyObject *
102 get_attr (PyObject *obj, PyObject *attr_name)
103 {
104   if (PyString_Check (attr_name)
105 #ifdef IS_PY3K
106       && ! PyUnicode_CompareWithASCIIString (attr_name, "value"))
107 #else
108       && ! strcmp (PyString_AsString (attr_name), "value"))
109 #endif
110     {
111       parmpy_object *self = (parmpy_object *) obj;
112
113       return gdbpy_parameter_value (self->type, &self->value);
114     }
115
116   return PyObject_GenericGetAttr (obj, attr_name);
117 }
118
119 /* Set a parameter value from a Python value.  Return 0 on success.  Returns
120    -1 on error, with a python exception set.  */
121 static int
122 set_parameter_value (parmpy_object *self, PyObject *value)
123 {
124   int cmp;
125
126   switch (self->type)
127     {
128     case var_string:
129     case var_string_noescape:
130     case var_optional_filename:
131     case var_filename:
132       if (! gdbpy_is_string (value)
133           && (self->type == var_filename
134               || value != Py_None))
135         {
136           PyErr_SetString (PyExc_RuntimeError,
137                            _("String required for filename."));
138
139           return -1;
140         }
141       if (value == Py_None)
142         {
143           xfree (self->value.stringval);
144           if (self->type == var_optional_filename)
145             self->value.stringval = xstrdup ("");
146           else
147             self->value.stringval = NULL;
148         }
149       else
150         {
151           gdb::unique_xmalloc_ptr<char>
152             string (python_string_to_host_string (value));
153           if (string == NULL)
154             return -1;
155
156           xfree (self->value.stringval);
157           self->value.stringval = string.release ();
158         }
159       break;
160
161     case var_enum:
162       {
163         int i;
164
165         if (! gdbpy_is_string (value))
166           {
167             PyErr_SetString (PyExc_RuntimeError,
168                              _("ENUM arguments must be a string."));
169             return -1;
170           }
171
172         gdb::unique_xmalloc_ptr<char>
173           str (python_string_to_host_string (value));
174         if (str == NULL)
175           return -1;
176         for (i = 0; self->enumeration[i]; ++i)
177           if (! strcmp (self->enumeration[i], str.get ()))
178             break;
179         if (! self->enumeration[i])
180           {
181             PyErr_SetString (PyExc_RuntimeError,
182                              _("The value must be member of an enumeration."));
183             return -1;
184           }
185         self->value.cstringval = self->enumeration[i];
186         break;
187       }
188
189     case var_boolean:
190       if (! PyBool_Check (value))
191         {
192           PyErr_SetString (PyExc_RuntimeError,
193                            _("A boolean argument is required."));
194           return -1;
195         }
196       cmp = PyObject_IsTrue (value);
197       if (cmp < 0)
198           return -1;
199       self->value.boolval = cmp;
200       break;
201
202     case var_auto_boolean:
203       if (! PyBool_Check (value) && value != Py_None)
204         {
205           PyErr_SetString (PyExc_RuntimeError,
206                            _("A boolean or None is required"));
207           return -1;
208         }
209
210       if (value == Py_None)
211         self->value.autoboolval = AUTO_BOOLEAN_AUTO;
212       else
213         {
214           cmp = PyObject_IsTrue (value);
215           if (cmp < 0 )
216             return -1;  
217           if (cmp == 1)
218             self->value.autoboolval = AUTO_BOOLEAN_TRUE;
219           else
220             self->value.autoboolval = AUTO_BOOLEAN_FALSE;
221         }
222       break;
223
224     case var_integer:
225     case var_zinteger:
226     case var_uinteger:
227     case var_zuinteger:
228     case var_zuinteger_unlimited:
229       {
230         long l;
231         int ok;
232
233         if (! PyInt_Check (value))
234           {
235             PyErr_SetString (PyExc_RuntimeError,
236                              _("The value must be integer."));
237             return -1;
238           }
239
240         if (! gdb_py_int_as_long (value, &l))
241           return -1;
242
243         switch (self->type)
244           {
245           case var_uinteger:
246             if (l == 0)
247               l = UINT_MAX;
248             /* Fall through.  */
249           case var_zuinteger:
250             ok = (l >= 0 && l <= UINT_MAX);
251             break;
252
253           case var_zuinteger_unlimited:
254             ok = (l >= -1 && l <= INT_MAX);
255             break;
256
257           case var_integer:
258             ok = (l >= INT_MIN && l <= INT_MAX);
259             if (l == 0)
260               l = INT_MAX;
261             break;
262
263           case var_zinteger:
264             ok = (l >= INT_MIN && l <= INT_MAX);
265             break;
266
267           default:
268             gdb_assert_not_reached ("unknown var_ constant");
269           }
270
271         if (! ok)
272           {
273             PyErr_SetString (PyExc_RuntimeError,
274                              _("Range exceeded."));
275             return -1;
276           }
277
278         if (self->type == var_uinteger || self->type == var_zuinteger)
279           self->value.uintval = (unsigned) l;
280         else
281           self->value.intval = (int) l;
282         break;
283       }
284
285     default:
286       PyErr_SetString (PyExc_RuntimeError,
287                        _("Unhandled type in parameter value."));
288       return -1;
289     }
290
291   return 0;
292 }
293
294 /* Set an attribute.  Returns -1 on error, with a python exception set.  */
295 static int
296 set_attr (PyObject *obj, PyObject *attr_name, PyObject *val)
297 {
298   if (PyString_Check (attr_name)
299 #ifdef IS_PY3K
300       && ! PyUnicode_CompareWithASCIIString (attr_name, "value"))
301 #else
302       && ! strcmp (PyString_AsString (attr_name), "value"))
303 #endif
304     {
305       if (!val)
306         {
307           PyErr_SetString (PyExc_RuntimeError,
308                            _("Cannot delete a parameter's value."));
309           return -1;
310         }
311       return set_parameter_value ((parmpy_object *) obj, val);
312     }
313
314   return PyObject_GenericSetAttr (obj, attr_name, val);
315 }
316
317 /* A helper function which returns a documentation string for an
318    object. */
319
320 static gdb::unique_xmalloc_ptr<char>
321 get_doc_string (PyObject *object, PyObject *attr)
322 {
323   gdb::unique_xmalloc_ptr<char> result;
324
325   if (PyObject_HasAttr (object, attr))
326     {
327       gdbpy_ref<> ds_obj (PyObject_GetAttr (object, attr));
328
329       if (ds_obj != NULL && gdbpy_is_string (ds_obj.get ()))
330         {
331           result = python_string_to_host_string (ds_obj.get ());
332           if (result == NULL)
333             gdbpy_print_stack ();
334         }
335     }
336   if (! result)
337     result.reset (xstrdup (_("This command is not documented.")));
338   return result;
339 }
340
341 /* Helper function which will execute a METHOD in OBJ passing the
342    argument ARG.  ARG can be NULL.  METHOD should return a Python
343    string.  If this function returns NULL, there has been an error and
344    the appropriate exception set.  */
345 static gdb::unique_xmalloc_ptr<char>
346 call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
347 {
348   gdb::unique_xmalloc_ptr<char> data;
349   gdbpy_ref<> result (PyObject_CallMethodObjArgs (obj, method, arg, NULL));
350
351   if (result == NULL)
352     return NULL;
353
354   if (gdbpy_is_string (result.get ()))
355     {
356       data = python_string_to_host_string (result.get ());
357       if (! data)
358         return NULL;
359     }
360   else
361     {
362       PyErr_SetString (PyExc_RuntimeError,
363                        _("Parameter must return a string value."));
364       return NULL;
365     }
366
367   return data;
368 }
369
370 /* A callback function that is registered against the respective
371    add_setshow_* set_doc prototype.  This function calls the Python function
372    "get_set_string" if it exists, which will return a string.  That string
373    is then printed.  If "get_set_string" does not exist, or returns an
374    empty string, then nothing is printed.  */
375 static void
376 get_set_value (const char *args, int from_tty,
377                struct cmd_list_element *c)
378 {
379   PyObject *obj = (PyObject *) get_cmd_context (c);
380   gdb::unique_xmalloc_ptr<char> set_doc_string;
381
382   gdbpy_enter enter_py (get_current_arch (), current_language);
383   gdbpy_ref<> set_doc_func (PyString_FromString ("get_set_string"));
384
385   if (set_doc_func == NULL)
386     {
387       gdbpy_print_stack ();
388       return;
389     }
390
391   if (PyObject_HasAttr (obj, set_doc_func.get ()))
392     {
393       set_doc_string = call_doc_function (obj, set_doc_func.get (), NULL);
394       if (! set_doc_string)
395         gdbpy_handle_exception ();
396     }
397
398   const char *str = set_doc_string.get ();
399   if (str != nullptr && str[0] != '\0')
400     fprintf_filtered (gdb_stdout, "%s\n", str);
401 }
402
403 /* A callback function that is registered against the respective
404    add_setshow_* show_doc prototype.  This function will either call
405    the Python function "get_show_string" or extract the Python
406    attribute "show_doc" and return the contents as a string.  If
407    neither exist, insert a string indicating the Parameter is not
408    documented.  */
409 static void
410 get_show_value (struct ui_file *file, int from_tty,
411                 struct cmd_list_element *c,
412                 const char *value)
413 {
414   PyObject *obj = (PyObject *) get_cmd_context (c);
415   gdb::unique_xmalloc_ptr<char> show_doc_string;
416
417   gdbpy_enter enter_py (get_current_arch (), current_language);
418   gdbpy_ref<> show_doc_func (PyString_FromString ("get_show_string"));
419
420   if (show_doc_func == NULL)
421     {
422       gdbpy_print_stack ();
423       return;
424     }
425
426   if (PyObject_HasAttr (obj, show_doc_func.get ()))
427     {
428       gdbpy_ref<> val_obj (PyString_FromString (value));
429
430       if (val_obj == NULL)
431         {
432           gdbpy_print_stack ();
433           return;
434         }
435
436       show_doc_string = call_doc_function (obj, show_doc_func.get (),
437                                            val_obj.get ());
438       if (! show_doc_string)
439         {
440           gdbpy_print_stack ();
441           return;
442         }
443
444       fprintf_filtered (file, "%s\n", show_doc_string.get ());
445     }
446   else
447     {
448       /* We have to preserve the existing < GDB 7.3 API.  If a
449          callback function does not exist, then attempt to read the
450          show_doc attribute.  */
451       show_doc_string  = get_doc_string (obj, show_doc_cst);
452       fprintf_filtered (file, "%s %s\n", show_doc_string.get (), value);
453     }
454 }
455 \f
456
457 /* A helper function that dispatches to the appropriate add_setshow
458    function.  */
459 static void
460 add_setshow_generic (int parmclass, enum command_class cmdclass,
461                      gdb::unique_xmalloc_ptr<char> cmd_name,
462                      parmpy_object *self,
463                      const char *set_doc, const char *show_doc,
464                      const char *help_doc,
465                      struct cmd_list_element **set_list,
466                      struct cmd_list_element **show_list)
467 {
468   struct cmd_list_element *param = NULL;
469   const char *tmp_name = NULL;
470
471   switch (parmclass)
472     {
473     case var_boolean:
474
475       add_setshow_boolean_cmd (cmd_name.get (), cmdclass,
476                                &self->value.boolval, set_doc, show_doc,
477                                help_doc, get_set_value, get_show_value,
478                                set_list, show_list);
479
480       break;
481
482     case var_auto_boolean:
483       add_setshow_auto_boolean_cmd (cmd_name.get (), cmdclass,
484                                     &self->value.autoboolval,
485                                     set_doc, show_doc, help_doc,
486                                     get_set_value, get_show_value,
487                                     set_list, show_list);
488       break;
489
490     case var_uinteger:
491       add_setshow_uinteger_cmd (cmd_name.get (), cmdclass,
492                                 &self->value.uintval, set_doc, show_doc,
493                                 help_doc, get_set_value, get_show_value,
494                                 set_list, show_list);
495       break;
496
497     case var_integer:
498       add_setshow_integer_cmd (cmd_name.get (), cmdclass,
499                                &self->value.intval, set_doc, show_doc,
500                                help_doc, get_set_value, get_show_value,
501                                set_list, show_list); break;
502
503     case var_string:
504       add_setshow_string_cmd (cmd_name.get (), cmdclass,
505                               &self->value.stringval, set_doc, show_doc,
506                               help_doc, get_set_value, get_show_value,
507                               set_list, show_list); break;
508
509     case var_string_noescape:
510       add_setshow_string_noescape_cmd (cmd_name.get (), cmdclass,
511                                        &self->value.stringval,
512                                        set_doc, show_doc, help_doc,
513                                        get_set_value, get_show_value,
514                                        set_list, show_list);
515
516       break;
517
518     case var_optional_filename:
519       add_setshow_optional_filename_cmd (cmd_name.get (), cmdclass,
520                                          &self->value.stringval, set_doc,
521                                          show_doc, help_doc, get_set_value,
522                                          get_show_value, set_list,
523                                          show_list);
524       break;
525
526     case var_filename:
527       add_setshow_filename_cmd (cmd_name.get (), cmdclass,
528                                 &self->value.stringval, set_doc, show_doc,
529                                 help_doc, get_set_value, get_show_value,
530                                 set_list, show_list); break;
531
532     case var_zinteger:
533       add_setshow_zinteger_cmd (cmd_name.get (), cmdclass,
534                                 &self->value.intval, set_doc, show_doc,
535                                 help_doc, get_set_value, get_show_value,
536                                 set_list, show_list);
537       break;
538
539     case var_zuinteger:
540       add_setshow_zuinteger_cmd (cmd_name.get (), cmdclass,
541                                 &self->value.uintval, set_doc, show_doc,
542                                 help_doc, get_set_value, get_show_value,
543                                 set_list, show_list);
544       break;
545
546     case var_zuinteger_unlimited:
547       add_setshow_zuinteger_unlimited_cmd (cmd_name.get (), cmdclass,
548                                            &self->value.intval, set_doc,
549                                            show_doc, help_doc, get_set_value,
550                                            get_show_value,
551                                            set_list, show_list);
552       break;
553
554     case var_enum:
555       add_setshow_enum_cmd (cmd_name.get (), cmdclass, self->enumeration,
556                             &self->value.cstringval, set_doc, show_doc,
557                             help_doc, get_set_value, get_show_value,
558                             set_list, show_list);
559       /* Initialize the value, just in case.  */
560       self->value.cstringval = self->enumeration[0];
561       break;
562     }
563
564   /* Lookup created parameter, and register Python object against the
565      parameter context.  Perform this task against both lists.  */
566   tmp_name = cmd_name.get ();
567   param = lookup_cmd (&tmp_name, *show_list, "", NULL, 0, 1);
568   if (param)
569     set_cmd_context (param, self);
570
571   tmp_name = cmd_name.get ();
572   param = lookup_cmd (&tmp_name, *set_list, "", NULL, 0, 1);
573   if (param)
574     set_cmd_context (param, self);
575
576   /* We (unfortunately) currently leak the command name.  */
577   cmd_name.release ();
578 }
579
580 /* A helper which computes enum values.  Returns 1 on success.  Returns 0 on
581    error, with a python exception set.  */
582 static int
583 compute_enum_values (parmpy_object *self, PyObject *enum_values)
584 {
585   Py_ssize_t size, i;
586
587   if (! enum_values)
588     {
589       PyErr_SetString (PyExc_RuntimeError,
590                        _("An enumeration is required for PARAM_ENUM."));
591       return 0;
592     }
593
594   if (! PySequence_Check (enum_values))
595     {
596       PyErr_SetString (PyExc_RuntimeError,
597                        _("The enumeration is not a sequence."));
598       return 0;
599     }
600
601   size = PySequence_Size (enum_values);
602   if (size < 0)
603     return 0;
604   if (size == 0)
605     {
606       PyErr_SetString (PyExc_RuntimeError,
607                        _("The enumeration is empty."));
608       return 0;
609     }
610
611   gdb_argv holder (XCNEWVEC (char *, size + 1));
612   char **enumeration = holder.get ();
613
614   for (i = 0; i < size; ++i)
615     {
616       gdbpy_ref<> item (PySequence_GetItem (enum_values, i));
617
618       if (item == NULL)
619         return 0;
620       if (! gdbpy_is_string (item.get ()))
621         {
622           PyErr_SetString (PyExc_RuntimeError,
623                            _("The enumeration item not a string."));
624           return 0;
625         }
626       enumeration[i] = python_string_to_host_string (item.get ()).release ();
627       if (enumeration[i] == NULL)
628         return 0;
629     }
630
631   self->enumeration = const_cast<const char**> (holder.release ());
632   return 1;
633 }
634
635 /* Object initializer; sets up gdb-side structures for command.
636
637    Use: __init__(NAME, CMDCLASS, PARMCLASS, [ENUM])
638
639    NAME is the name of the parameter.  It may consist of multiple
640    words, in which case the final word is the name of the new command,
641    and earlier words must be prefix commands.
642
643    CMDCLASS is the kind of command.  It should be one of the COMMAND_*
644    constants defined in the gdb module.
645
646    PARMCLASS is the type of the parameter.  It should be one of the
647    PARAM_* constants defined in the gdb module.
648
649    If PARMCLASS is PARAM_ENUM, then the final argument should be a
650    collection of strings.  These strings are the valid values for this
651    parameter.
652
653    The documentation for the parameter is taken from the doc string
654    for the python class.
655
656    Returns -1 on error, with a python exception set.  */
657
658 static int
659 parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
660 {
661   parmpy_object *obj = (parmpy_object *) self;
662   const char *name;
663   gdb::unique_xmalloc_ptr<char> set_doc, show_doc, doc;
664   int parmclass, cmdtype;
665   PyObject *enum_values = NULL;
666   struct cmd_list_element **set_list, **show_list;
667
668   if (! PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass,
669                           &enum_values))
670     return -1;
671
672   if (cmdtype != no_class && cmdtype != class_run
673       && cmdtype != class_vars && cmdtype != class_stack
674       && cmdtype != class_files && cmdtype != class_support
675       && cmdtype != class_info && cmdtype != class_breakpoint
676       && cmdtype != class_trace && cmdtype != class_obscure
677       && cmdtype != class_maintenance)
678     {
679       PyErr_Format (PyExc_RuntimeError, _("Invalid command class argument."));
680       return -1;
681     }
682
683   if (parmclass != var_boolean /* ARI: var_boolean */
684       && parmclass != var_auto_boolean
685       && parmclass != var_uinteger && parmclass != var_integer
686       && parmclass != var_string && parmclass != var_string_noescape
687       && parmclass != var_optional_filename && parmclass != var_filename
688       && parmclass != var_zinteger && parmclass != var_zuinteger
689       && parmclass != var_zuinteger_unlimited && parmclass != var_enum)
690     {
691       PyErr_SetString (PyExc_RuntimeError,
692                        _("Invalid parameter class argument."));
693       return -1;
694     }
695
696   if (enum_values && parmclass != var_enum)
697     {
698       PyErr_SetString (PyExc_RuntimeError,
699                        _("Only PARAM_ENUM accepts a fourth argument."));
700       return -1;
701     }
702   if (parmclass == var_enum)
703     {
704       if (! compute_enum_values (obj, enum_values))
705         return -1;
706     }
707   else
708     obj->enumeration = NULL;
709   obj->type = (enum var_types) parmclass;
710   memset (&obj->value, 0, sizeof (obj->value));
711
712   gdb::unique_xmalloc_ptr<char> cmd_name
713     = gdbpy_parse_command_name (name, &set_list, &setlist);
714   if (cmd_name == nullptr)
715     return -1;
716
717   cmd_name = gdbpy_parse_command_name (name, &show_list, &showlist);
718   if (cmd_name == nullptr)
719     return -1;
720
721   set_doc = get_doc_string (self, set_doc_cst);
722   show_doc = get_doc_string (self, show_doc_cst);
723   doc = get_doc_string (self, gdbpy_doc_cst);
724
725   Py_INCREF (self);
726
727   try
728     {
729       add_setshow_generic (parmclass, (enum command_class) cmdtype,
730                            std::move (cmd_name), obj,
731                            set_doc.get (), show_doc.get (),
732                            doc.get (), set_list, show_list);
733     }
734   catch (const gdb_exception &except)
735     {
736       Py_DECREF (self);
737       gdbpy_convert_exception (except);
738       return -1;
739     }
740
741   return 0;
742 }
743
744 \f
745
746 /* Initialize the 'parameters' module.  */
747 int
748 gdbpy_initialize_parameters (void)
749 {
750   int i;
751
752   parmpy_object_type.tp_new = PyType_GenericNew;
753   if (PyType_Ready (&parmpy_object_type) < 0)
754     return -1;
755
756   set_doc_cst = PyString_FromString ("set_doc");
757   if (! set_doc_cst)
758     return -1;
759   show_doc_cst = PyString_FromString ("show_doc");
760   if (! show_doc_cst)
761     return -1;
762
763   for (i = 0; parm_constants[i].name; ++i)
764     {
765       if (PyModule_AddIntConstant (gdb_module,
766                                    parm_constants[i].name,
767                                    parm_constants[i].value) < 0)
768         return -1;
769     }
770
771   return gdb_pymodule_addobject (gdb_module, "Parameter",
772                                  (PyObject *) &parmpy_object_type);
773 }
774
775 \f
776
777 PyTypeObject parmpy_object_type =
778 {
779   PyVarObject_HEAD_INIT (NULL, 0)
780   "gdb.Parameter",                /*tp_name*/
781   sizeof (parmpy_object),         /*tp_basicsize*/
782   0,                              /*tp_itemsize*/
783   0,                              /*tp_dealloc*/
784   0,                              /*tp_print*/
785   0,                              /*tp_getattr*/
786   0,                              /*tp_setattr*/
787   0,                              /*tp_compare*/
788   0,                              /*tp_repr*/
789   0,                              /*tp_as_number*/
790   0,                              /*tp_as_sequence*/
791   0,                              /*tp_as_mapping*/
792   0,                              /*tp_hash */
793   0,                              /*tp_call*/
794   0,                              /*tp_str*/
795   get_attr,                       /*tp_getattro*/
796   set_attr,                       /*tp_setattro*/
797   0,                              /*tp_as_buffer*/
798   Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
799   "GDB parameter object",         /* tp_doc */
800   0,                              /* tp_traverse */
801   0,                              /* tp_clear */
802   0,                              /* tp_richcompare */
803   0,                              /* tp_weaklistoffset */
804   0,                              /* tp_iter */
805   0,                              /* tp_iternext */
806   0,                              /* tp_methods */
807   0,                              /* tp_members */
808   0,                              /* tp_getset */
809   0,                              /* tp_base */
810   0,                              /* tp_dict */
811   0,                              /* tp_descr_get */
812   0,                              /* tp_descr_set */
813   0,                              /* tp_dictoffset */
814   parmpy_init,                    /* tp_init */
815   0,                              /* tp_alloc */
816 };
This page took 0.066973 seconds and 2 git commands to generate.