This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfa] expose gdb values to python, mark II


On Sat, Oct 04, 2008 at 07:22:09PM -0300, Thiago Jung Bauermann wrote:
> +Inferior values that are simple scalars can be used directly in
> +Python expressions that are valid for the value's data type  Here's
> +an example for an integer or floating-point value @code{some_val}:

Typo (missing period).

This only works for scalars (now including pointers), right?  Do you
have to call overloaded operators explicitly?

> +/* Returns a value object which is the sum of this value with the given
> +   integer argument.  */
> +static PyObject *
> +valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)

The comment is not accurate, this is more than sum.

> +{
> +  long l;
> +  double d;
> +  struct value *res_val = NULL;	  /* Initialize to appease gcc warning.  */
> +  struct value *other_val;
> +  value_object *self_value;
> +  volatile struct gdb_exception except;
> +
> +  /* If the gdb.Value object is the second operand, then it will be passed
> +     to us as the OTHER argument, and SELF will be an entirely different
> +     kind of object, altogether.  Swap them to avoid surprises.  */
> +  if (!PyObject_TypeCheck (self, &value_object_type))
> +    {
> +      PyObject *tmp;
> +
> +      tmp = self;
> +      self = other;
> +      other = tmp;
> +    }

And since it's more than sum.... what about "1 - foo"?

Otherwise, OK.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]