Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Siva Chandra <sivachandra@google.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [Patch v18 4/4] Add xmethod support to the Python API
Date: Wed, 28 May 2014 20:31:00 -0000	[thread overview]
Message-ID: <CADPb22Td7V9SfSNr3r3hXW7NoeKEQwJ4wnwoMUT0CROHhPbDoQ@mail.gmail.com> (raw)
In-Reply-To: <CAGyQ6gzxSMKMZMivz48DvgzuDQ+CRc+mHaTq4oBdk8-iB8dt9A@mail.gmail.com>

On Wed, May 28, 2014 at 12:12 PM, Siva Chandra <sivachandra@google.com> wrote:
> On Tue, May 27, 2014 at 10:41 PM, Doug Evans <xdje42@gmail.com> wrote:
>> Another thing occurs to me.
>> Pretty-printers are invoked, initially, via __call__, not via a "print"
>> method or some such.
>> It would be more python-esque if XMethodMatcher.match was renamed __call__
>> and XMethodWorker.invoke was renamed __call__.
>
> While I agree XMethodWorker.invoke can be removed and we could make
> XMethodWorker a callable, I am not sure we want to make XMethodMatcher
> a callable. I know pretty printers are callables but do not know the
> reason why they are so (probably because there is an old way and a new
> way of writing pretty printers and both have to be supported). For me,
> a __call__ method in Python is like operator() in C++ which I feel
> should be used only if it is meaningful to make the objects callable.
> Even for the XMethodWorker, I preferred a method 'invoke' over making
> workers callables because they are named as workers and not as
> methods. The only reason I had to bring in the notion of XMethods
> (which are used only for enable/disable) and XMethodWorker is because
> I had to ape the pretty printer setup. I propose a slightly different
> design here which does not ape the pretty printers completely but
> makes it less confusing:
>
> 1. Have XMethodMatchers with a method named 'match'. Matchers have an
> attribute 'enabled'. GDB invokes the 'match' method on registered
> matchers if they are enabled. On a match, the matcher returns a
> sequence of matching and enabled XMethods. See #2 to know what
> XMethods are. An XMethodMatcher also has an attribute 'method', which
> is a sequence of XMethods the matcher manages. This provides a way to
> enable/disable individual XMethods from enable/disable commands.
> 2. Have XMethods which are callables, but also have a method
> 'get_arg_types'. XMethods also have an 'enabled' attribute to indicate
> whether they are enabled or not. GDB calls an XMethod (they are
> callables) if it determines that the XMethod is the best overload
> match.

By analogy, what this does is merge SubPrettyPrinter with the
pretty-printer worker object.

FAOD,

XMethodMatcher
  attributes: name, enabled, methods, match

XMethod
  attributes: name, enabled, get_arg_types, __call__

"works for me"


      reply	other threads:[~2014-05-28 20:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 21:02 Siva Chandra
2014-05-25 23:31 ` Doug Evans
2014-05-28  5:02   ` Doug Evans
2014-05-28 20:44     ` Siva Chandra
2014-05-28 20:58       ` Doug Evans
2014-05-28  5:41 ` Doug Evans
2014-05-28 19:12   ` Siva Chandra
2014-05-28 20:31     ` Doug Evans [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADPb22Td7V9SfSNr3r3hXW7NoeKEQwJ4wnwoMUT0CROHhPbDoQ@mail.gmail.com \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sivachandra@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox