From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4720 invoked by alias); 2 Jun 2014 03:59:34 -0000 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 Received: (qmail 4707 invoked by uid 89); 2 Jun 2014 03:59:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pb0-f46.google.com Received: from mail-pb0-f46.google.com (HELO mail-pb0-f46.google.com) (209.85.160.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 02 Jun 2014 03:59:31 +0000 Received: by mail-pb0-f46.google.com with SMTP id rq2so3748045pbb.19 for ; Sun, 01 Jun 2014 20:59:29 -0700 (PDT) X-Received: by 10.69.20.10 with SMTP id gy10mr37595753pbd.162.1401681569788; Sun, 01 Jun 2014 20:59:29 -0700 (PDT) Received: from seba.sebabeach.org.gmail.com (173-13-178-50-sfba.hfc.comcastbusiness.net. [173.13.178.50]) by mx.google.com with ESMTPSA id eh4sm17850856pbc.79.2014.06.01.20.59.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jun 2014 20:59:29 -0700 (PDT) From: Doug Evans To: Siva Chandra Cc: gdb-patches Subject: Re: [PATCH v19 1/4] Add xmethod documentation and NEWS entry References: Date: Mon, 02 Jun 2014 03:59:00 -0000 In-Reply-To: (Siva Chandra's message of "Fri, 30 May 2014 15:56:08 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg00008.txt.bz2 Siva Chandra writes: > 2014-05-30 Siva Chandra Reddy > > * NEWS (Python Scripting): Add entry about the new xmethods > feature. > > doc/ > * python.texi (Xmethods In Python, XMethod API) > (Writing an Xmethod): New nodes. > (Python API): New menu entries "Xmethods In Python", > "Xmethod API", "Writing an Xmethod". > > [...] > > +@node Writing an Xmethod > +@subsubsection Writing an Xmethod > +@cindex writing xmethods in Python > + > +Implementing xmethods in Python will require implementing xmethod > +matchers and xmethod workers (@pxref{Xmethods In Python}). Consider > +the following C@t{++} class: > + > +@smallexample > +class MyClass > +@{ > +public: > + MyClass (int a) : a_(a) @{ @} > + > + int geta (void) @{ return a_; @} > + int operator+ (int b); The corresponding python method takes a MyClass object for "b", not an int. Either they should match, or the docs should say why they're different. [There's no reason the user can't add new methods to an object with xmethods, but at the moment I think the reader will find the difference confusing unless there's an explanation of why.] > +class MyClassWorker_plus(gdb.xmethod.XMethodWorker): > + def get_arg_types(self): > + return gdb.lookup_type('MyClass') > + > + def __call__(self, obj, other): > + return obj['a_'] + other['a_'] > +@end smallexample LGTM with that fixed.