This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[python][rfc] Rename methods and functions related topretty-printing.


Nothing special to mention about this one. 


2008-12-05  Thiago Jung Bauermann  <bauerman@br.ibm.com>

gdb/ 
	* python/python-objfile.c (objfpy_filename): Rename to ...
	(objfpy_get_filename): ... this. Change to conform to Python getter
	signature.
	(objfile_getset): Add entry for `filename'.
	(symtab_object_methods): Remove.
	(objfile_object_type): Unset tp_methods field.
	* python/python.c (get_parameter): Rename to ...
	(gdbpy_parameter): ... this.
	(gdbpy_get_objfiles): Rename to ...
	(gdbpy_objfiles): ... this.
	(gdbpy_get_default_visualizers): Rename to ...
	(gdbpy_default_visualizers): ... this.
	(GdbMethods): Rename `get_parameter' to `parameter',
	`get_default_visualizer' to `default_visualizer',
	`get_current_objfile' to `current_objfile' and `get_objfiles' to
	`objfiles'.
	* python/lib/gdb/command/backtrace.py: Adjust to use gdb.Symtab and
	gdb.Symtab_and_line attributes rather than functions.
	* python/lib/gdb/libstdcxx/v6/printers.py: Adjust to use new gdb
	module function names.

gdb/doc/
	* gdb.texinfo: Fix references to renamed gdb module functions.

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 186ce69..54027f2 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -18073,22 +18073,22 @@ command as having originated from the user invoking it interactively.
 It must be a boolean value.  If omitted, it defaults to @code{False}.
 @end defun
 
-@findex gdb.get_current_objfile
-@defun get_current_objfile
+@findex gdb.current_objfile
+@defun current_objfile
 When auto-loading a Python script (@pxref{Auto-loading}), @var{GDBN}
 sets the ``current objfile'' to the corresponding objfile.  This
 function returns the current objfile.  If there is no current objfile,
 this function returns @code{None}.
 @end defun
 
-@findex gdb.get_objfiles
-@defun get_objfiles
+@findex gdb.objfiles
+@defun objfiles
 Return a sequence of all the objfiles current known to @var{GDBN}.
 @xref{Objfiles in Python}.
 @end defun
 
-@findex gdb.get_parameter
-@defun get_parameter parameter
+@findex gdb.parameter
+@defun parameter
 Return the value of a @value{GDBN} parameter.  @var{parameter} is a
 string naming the parameter to look up; @var{parameter} may contain
 spaces if the parameter has a multi-part name.  For example,
@@ -18164,7 +18164,7 @@ for the @samp{-gdb.py} file both in the directory associated with the
 application and the directory associated with the separate debug file.
 
 When reading a @samp{-gdb.py} file, @var{GDBN} sets the ``current
-objfile''.  This is available via the @code{gdb.get_current_objfile}
+objfile''.  This is available via the @code{gdb.current_objfile}
 function.  This can be useful for registering objfile-specific
 pretty-printers.
 
@@ -18656,7 +18656,7 @@ And then the corresponding contents of the auto-load file would be:
 
 @smallexample
 import gdb.libstdcxx.v6
-gdb.libstdcxx.v6.register_printers (gdb.get_current_objfile ())
+gdb.libstdcxx.v6.register_printers (gdb.current_objfile ())
 @end smallexample
 
 @node Threads In Python
@@ -19085,9 +19085,9 @@ files.  @var{GDBN} calls these symbol-containing files
 Each objfile is represented by an instance of the @code{gdb.Objfile}
 class.
 
-@defmethod Objfile get_filename
-Return the file name of the objfile as a string.
-@end defmethod
+@defivar Objfile filename
+The file name of the objfile as a string.
+@end defivar
 
 @defivar Objfile pretty_printers
 The @code{pretty_printers} attribute is used to look up
diff --git a/gdb/python/lib/gdb/libstdcxx/v6/printers.py b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
index d25b4db..a7964c5 100644
--- a/gdb/python/lib/gdb/libstdcxx/v6/printers.py
+++ b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
@@ -150,7 +150,7 @@ class StdStackOrQueuePrinter:
 
     def __init__ (self, typename, val):
         self.typename = typename
-        self.visualizer = gdb.get_default_visualizer(val['c'])
+        self.visualizer = gdb.default_visualizer(val['c'])
 
     def children (self):
         return self.visualizer.children()
@@ -388,7 +388,7 @@ class StdStringPrinter:
         # Look up the target encoding as late as possible.
         encoding = self.encoding
         if encoding is None:
-            encoding = gdb.get_parameter('target-charset')
+            encoding = gdb.parameter('target-charset')
         elif isinstance(encoding, WideEncoding):
             encoding = encoding.value
         return self.val['_M_dataplus']['_M_p'].string(encoding)
@@ -519,4 +519,4 @@ def register_libstdcxx_printers(obj):
     # Extensions.
     obj.pretty_printers['^__gnu_cxx::slist<.*>$'] = StdSlistPrinter
 
-register_libstdcxx_printers (gdb.get_current_objfile())
+register_libstdcxx_printers (gdb.current_objfile())
diff --git a/gdb/python/python-objfile.c b/gdb/python/python-objfile.c
index 335e05b..a225409 100644
--- a/gdb/python/python-objfile.c
+++ b/gdb/python/python-objfile.c
@@ -41,7 +41,7 @@ static const struct objfile_data *objfpy_objfile_data_key;
 
 /* An Objfile method which returns the objfile's file name, or None.  */
 static PyObject *
-objfpy_filename (PyObject *self, PyObject *args)
+objfpy_get_filename (PyObject *self, void *closure)
 {
   objfile_object *obj = (objfile_object *) self;
   if (obj->objfile && obj->objfile->name)
@@ -170,18 +170,13 @@ gdbpy_initialize_objfile (void)
 
 static PyGetSetDef objfile_getset[] =
 {
+  { "filename", objfpy_get_filename, NULL,
+    "The objfile's filename, or None.", NULL },
   { "pretty_printers", objfpy_get_printers, objfpy_set_printers,
-    "Pretty printers", NULL },
+    "Pretty printers.", NULL },
   { NULL }
 };
 
-static PyMethodDef objfile_object_methods[] =
-{
-  { "get_filename", objfpy_filename, METH_NOARGS,
-    "Return the objfile's filename, or None." },
-  {NULL}  /* Sentinel */
-};
-
 static PyTypeObject objfile_object_type =
 {
   PyObject_HEAD_INIT (NULL)
@@ -212,7 +207,7 @@ static PyTypeObject objfile_object_type =
   0,				  /* tp_weaklistoffset */
   0,				  /* tp_iter */
   0,				  /* tp_iternext */
-  objfile_object_methods,	  /* tp_methods */
+  0,				  /* tp_methods */
   0,				  /* tp_members */
   objfile_getset,		  /* tp_getset */
   0,				  /* tp_base */
diff --git a/gdb/python/python.c b/gdb/python/python.c
index dde2789..e7f1652 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -223,7 +223,7 @@ gdbpy_parameter_value (enum var_types type, void *var)
    value.  */
 
 static PyObject *
-get_parameter (PyObject *self, PyObject *args)
+gdbpy_parameter (PyObject *self, PyObject *args)
 {
   struct cmd_list_element *alias, *prefix, *cmd;
   char *arg, *newarg;
@@ -665,7 +665,7 @@ gdbpy_get_current_objfile (PyObject *unused1, PyObject *unused2)
 
 /* Return a sequence holding all the Objfiles.  */
 static PyObject *
-gdbpy_get_objfiles (PyObject *unused1, PyObject *unused2)
+gdbpy_objfiles (PyObject *unused1, PyObject *unused2)
 {
   struct objfile *objf;
   PyObject *list;
@@ -1103,7 +1103,7 @@ gdbpy_get_varobj_pretty_printer (struct type *type)
    pretty printer instance, or None.  This function is useful as an
    argument to the MI command -var-set-visualizer.  */
 static PyObject *
-gdbpy_get_default_visualizer (PyObject *self, PyObject *args)
+gdbpy_default_visualizer (PyObject *self, PyObject *args)
 {
   PyObject *val_obj;
   PyObject *cons, *printer = NULL;
@@ -1348,18 +1348,18 @@ static PyMethodDef GdbMethods[] =
     "Execute a gdb command" },
   { "cli", gdbpy_cli, METH_NOARGS,
     "Enter the gdb CLI" },
-  { "get_parameter", get_parameter, METH_VARARGS,
+  { "parameter", gdbpy_parameter, METH_VARARGS,
     "Return a gdb parameter's value" },
 
   { "breakpoints", gdbpy_breakpoints, METH_NOARGS,
     "Return a tuple of all breakpoint objects" },
 
-  { "get_default_visualizer", gdbpy_get_default_visualizer, METH_VARARGS,
+  { "default_visualizer", gdbpy_default_visualizer, METH_VARARGS,
     "Find the default visualizer for a Value." },
 
-  { "get_current_objfile", gdbpy_get_current_objfile, METH_NOARGS,
+  { "current_objfile", gdbpy_get_current_objfile, METH_NOARGS,
     "Return the current Objfile being loaded, or None." },
-  { "get_objfiles", gdbpy_get_objfiles, METH_NOARGS,
+  { "objfiles", gdbpy_objfiles, METH_NOARGS,
     "Return a sequence of all loaded objfiles." },
 
   { "frames", gdbpy_frames, METH_NOARGS,
-- 
1.5.6.3



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]