/* Python function to set the (Ada) task of a breakpoint.  */
static int
bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
{
    gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
    long id;
    int valid_id = 0;
    volatile struct gdb_exception except;

    BPPY_SET_REQUIRE_VALID (self_bp);

    if (newvalue == NULL)
    {
        PyErr_SetString (PyExc_TypeError,
                         _("Cannot delete `task' attribute."));
        return -1;
    }
    else if (PyInt_Check (newvalue))
    {
        if (! gdb_py_int_as_long (newvalue, &id))
            return -1;

        TRY_CATCH (except, RETURN_MASK_ALL)
        {
            valid_id = valid_task_id (id);
        }
        GDB_PY_SET_HANDLE_EXCEPTION (except);

        if (! valid_id)
        {
            PyErr_SetString (PyExc_RuntimeError,
                             _("Invalid task ID."));
            return -1;
        }
    }
/* Python function to set the hit count of a breakpoint.  */
static int
bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
{
  breakpoint_object *self_bp = (breakpoint_object *) self;

  BPPY_SET_REQUIRE_VALID (self_bp);

  if (newvalue == NULL)
    {
      PyErr_SetString (PyExc_TypeError, 
		       _("Cannot delete `hit_count' attribute."));
      return -1;
    }
  else
    {
      long value;

      if (! gdb_py_int_as_long (newvalue, &value))
	return -1;

      if (value != 0)
	{
	  PyErr_SetString (PyExc_AttributeError,
			   _("The value of `hit_count' must be zero."));
	  return -1;
	}
    }

  self_bp->bp->hit_count = 0;

  return 0;
}
/* Python function to set the ignore count of a breakpoint.  */
static int
bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
{
  breakpoint_object *self_bp = (breakpoint_object *) self;
  long value;

  BPPY_SET_REQUIRE_VALID (self_bp);

  if (newvalue == NULL)
    {
      PyErr_SetString (PyExc_TypeError,
		       _("Cannot delete `ignore_count' attribute."));
      return -1;
    }
  else if (! PyInt_Check (newvalue))
    {
      PyErr_SetString (PyExc_TypeError,
		       _("The value of `ignore_count' must be an integer."));
      return -1;
    }

  if (! gdb_py_int_as_long (newvalue, &value))
    return -1;

  if (value < 0)
    value = 0;
  set_ignore_count (self_bp->number, (int) value, 0);

  return 0;
}
/* Python function to set the thread of a breakpoint.  */
static int
bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
{
    gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
    long id;

    BPPY_SET_REQUIRE_VALID (self_bp);

    if (newvalue == NULL)
    {
        PyErr_SetString (PyExc_TypeError,
                         _("Cannot delete `thread' attribute."));
        return -1;
    }
    else if (PyInt_Check (newvalue))
    {
        if (! gdb_py_int_as_long (newvalue, &id))
            return -1;

        if (! valid_thread_id (id))
        {
            PyErr_SetString (PyExc_RuntimeError,
                             _("Invalid thread ID."));
            return -1;
        }
    }
    else if (newvalue == Py_None)
        id = -1;
    else
    {
        PyErr_SetString (PyExc_TypeError,
                         _("The value of `thread' must be an integer or None."));
        return -1;
    }

    breakpoint_set_thread (self_bp->bp, id);

    return 0;
}