This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v19 1/4] Add xmethod documentation and NEWS entry
- From: Doug Evans <xdje42 at gmail dot com>
- To: Siva Chandra <sivachandra at google dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Sun, 01 Jun 2014 20:59:11 -0700
- Subject: Re: [PATCH v19 1/4] Add xmethod documentation and NEWS entry
- Authentication-results: sourceware.org; auth=none
- References: <CAGyQ6gwMjY2D56+NCd51jUEhiXn9rzhSDsmt6NhcPGskL9tArA at mail dot gmail dot com>
Siva Chandra <sivachandra@google.com> writes:
> 2014-05-30 Siva Chandra Reddy <sivachandra@google.com>
>
> * 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.