Fix documentation for Type.template_argument.

Message ID 1403636496-9795-1-git-send-email-jlebar@google.com
State New, archived
Headers

Commit Message

Justin Lebar June 24, 2014, 7:01 p.m. UTC
  In the Python API, Type.template_argument(n) returns either a gdb.Type
or a gdb.Value, depending on whether the n'th template argument is a C++
type or a C++ value.

Also add a note that Type.template_argument(n) throws an exception if n
is out of range (as opposed to, say, returning None).

There's one piece of the documentation I still don't understand:

> If block is given, then name is looked up in that scope. Otherwise, it
> is searched for globally.

What is 'name', exactly, and why are we looking it up?  I'd be happy to
fix this up if we could clarify this, but otherwise this patch stands on
its own.

2014-06-18  Justin Lebar <jlebar@google.com>

	* python.texi (Types In Python): Type.template_argument(n) returns a
	gdb.Value or a gdb.Type and throws an exception if n is out of
	range.
---
 gdb/doc/python.texi | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Comments

Eli Zaretskii June 24, 2014, 7:19 p.m. UTC | #1
> From: Justin Lebar <jlebar@google.com>
> Cc: Justin Lebar <jlebar@google.com>
> Date: Tue, 24 Jun 2014 12:01:36 -0700
> 
> -If this @code{gdb.Type} is not a template type, this will throw an
> -exception.  Ordinarily, only C@t{++} code will have template types.
> +If this @code{gdb.Type} is not a template type, or if the type has fewer
> +than N template arguments, this will throw an exception.  Ordinarily,
        ^
@var{n}

Otherwise, the patch is OK Texinfo-wise; I don't know enough about
these issues to tell whether the content is correct, nor can I answere
your question.

Thanks.
  

Patch

diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 4688783..f9e0b0c 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -1048,11 +1048,12 @@  exception.
 
 @defun Type.template_argument (n @r{[}, block@r{]})
 If this @code{gdb.Type} is an instantiation of a template, this will
-return a new @code{gdb.Type} which represents the type of the
-@var{n}th template argument.
+return a new @code{gdb.Value} or @code{gdb.Type} which represents the
+value of the @var{n}th template argument (indexed starting at 0).
 
-If this @code{gdb.Type} is not a template type, this will throw an
-exception.  Ordinarily, only C@t{++} code will have template types.
+If this @code{gdb.Type} is not a template type, or if the type has fewer
+than N template arguments, this will throw an exception.  Ordinarily,
+only C@t{++} code will have template types.
 
 If @var{block} is given, then @var{name} is looked up in that scope.
 Otherwise, it is searched for globally.