/* GDB parameters implemented in Python
- Copyright (C) 2008-2013 Free Software Foundation, Inc.
+ Copyright (C) 2008-2015 Free Software Foundation, Inc.
This file is part of GDB.
#include "defs.h"
#include "value.h"
-#include "exceptions.h"
#include "python-internal.h"
#include "charset.h"
#include "gdbcmd.h"
typedef struct parmpy_object parmpy_object;
-static PyTypeObject parmpy_object_type
+extern PyTypeObject parmpy_object_type
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("parmpy_object");
/* Some handy string constants. */
&& (self->type == var_filename
|| value != Py_None))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("String required for filename."));
return -1;
if (! gdbpy_is_string (value))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("ENUM arguments must be a string."));
return -1;
}
case var_boolean:
if (! PyBool_Check (value))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("A boolean argument is required."));
return -1;
}
cmp = PyObject_IsTrue (value);
- if (cmp < 0)
+ if (cmp < 0)
return -1;
self->value.intval = cmp;
break;
{
cmp = PyObject_IsTrue (value);
if (cmp < 0 )
- return -1;
+ return -1;
if (cmp == 1)
self->value.autoboolval = AUTO_BOOLEAN_TRUE;
- else
+ else
self->value.autoboolval = AUTO_BOOLEAN_FALSE;
}
break;
if (! PyInt_Check (value))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("The value must be integer."));
return -1;
}
if (! ok)
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("Range exceeded."));
return -1;
}
}
default:
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("Unhandled type in parameter value."));
return -1;
}
if (! PySequence_Check (enum_values))
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("The enumeration is not a sequence."));
return 0;
}
return 0;
if (size == 0)
{
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("The enumeration is empty."));
return 0;
}
{
Py_DECREF (item);
do_cleanups (back_to);
- PyErr_SetString (PyExc_RuntimeError,
+ PyErr_SetString (PyExc_RuntimeError,
_("The enumeration item not a string."));
return 0;
}
int parmclass, cmdtype;
PyObject *enum_values = NULL;
struct cmd_list_element **set_list, **show_list;
- volatile struct gdb_exception except;
if (! PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass,
&enum_values))
Py_INCREF (self);
- TRY_CATCH (except, RETURN_MASK_ALL)
+ TRY
{
add_setshow_generic (parmclass, (enum command_class) cmdtype,
cmd_name, obj,
set_doc, show_doc,
doc, set_list, show_list);
}
- if (except.reason < 0)
+ CATCH (except, RETURN_MASK_ALL)
{
xfree (cmd_name);
xfree (set_doc);
"%s", except.message);
return -1;
}
+ END_CATCH
+
return 0;
}
\f
-static PyTypeObject parmpy_object_type =
+PyTypeObject parmpy_object_type =
{
PyVarObject_HEAD_INIT (NULL, 0)
"gdb.Parameter", /*tp_name*/