From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30385 invoked by alias); 14 Oct 2008 12:35:27 -0000 Received: (qmail 30376 invoked by uid 22791); 14 Oct 2008 12:35:27 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 14 Oct 2008 12:34:43 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 712F1106D7; Tue, 14 Oct 2008 12:34:41 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 4F4E910001; Tue, 14 Oct 2008 12:34:41 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1Kpj6m-00027S-QN; Tue, 14 Oct 2008 08:34:40 -0400 Date: Tue, 14 Oct 2008 12:35:00 -0000 From: Daniel Jacobowitz To: Thiago Jung Bauermann Cc: gdb-patches@sources.redhat.com Subject: Re: [rfa] expose gdb values to python, mark II Message-ID: <20081014123440.GA7842@caradoc.them.org> Mail-Followup-To: Thiago Jung Bauermann , gdb-patches@sources.redhat.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2008-05-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-10/txt/msg00348.txt.bz2 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