RFA: document Value.__init__ (Was: Python API questions and use cases)

Tom Tromey
2010-09-21T20:06:25Z

>>>>> "Joel" == Joel Borggrén-Franck <joel.borggren.franck@gmail.com> writes:

Joel> I can't find documentation for the constructor André showed me:
Joel> gdb.Value(addr).

Here is a patch to document this constructor.

Ok?

Tom

2010-09-21 Tom Tromey <tromey@redhat.com>

* gdb.texinfo (Values From Inferior): Mention Value.__init__.

Index: gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.764
diff -u -r1.764 gdb.texinfo
--- gdb.texinfo 15 Sep 2010 19:31:59 -0000 1.764
+++ gdb.texinfo 21 Sep 2010 20:05:54 -0000
@@ -20774,6 +20774,22 @@
The following methods are provided:

@table @code
+@defmethod Value __init__ @var{val}
+Many Python values can be converted directly to a @code{gdb.Value} via
+this object initializer. Specifically, Python booleans are converted
+to boolean type from the current language; Python integers are
+converted to the C @code{long} type for the current architecture;
+Python longs are converted to the C @code{long long} type for the
+current architecture; Python floats are converted to the C
+@code{double} type for the current architecture; and Python strings
+are converted to target strings, using the current target encoding.
+
+@code{val} can also be a @code{gdb.Value}, in which case a copy of the
+value is returned, or a @code{gdb.LazyString} (@pxref{Lazy Strings In
+Python}), in which case the lazy string's @code{value} method is
+called, and its result is returned.
+@end defmethod
+
@defmethod Value cast type
Return a new instance of @code{gdb.Value} that is the result of
casting this instance to the type described by @var{type}, which must