From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Improve comments on pretty printer code
Date: Wed, 16 Nov 2022 13:38:15 +0000 [thread overview]
Message-ID: <20221116133815.1351836-1-jwakely@redhat.com> (raw)
Tested x86_64-linux with GDB 12.1. Pushed to trunk.
-- >8 --
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (is_specialization_of): Fix
incorrect terminology in docstring and describe arguments.
(FilteringTypePrinter): Add default argument for new parameter,
enhance docstring.
---
libstdc++-v3/python/libstdcxx/v6/printers.py | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index eaaf5e817c0..19c70d12035 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -166,7 +166,12 @@ def is_member_of_namespace(typ, *namespaces):
return False
def is_specialization_of(x, template_name):
- "Test if a type is a given template instantiation."
+ """
+ Test whether a type is a specialization of the named class template.
+ The type can be specified as a string or a gdb.Type object.
+ The template should be the name of a class template as a string,
+ without any 'std' qualification.
+ """
global _versioned_namespace
if type(x) is gdb.Type:
x = x.tag
@@ -2071,19 +2076,22 @@ class FilteringTypePrinter(object):
Args:
template (str): The class template to recognize.
name (str): The typedef-name that will be used instead.
- targ1 (str): The first template argument.
- If arg1 is provided (not None), match only template specializations
- with this type as the first template argument,
- e.g. if template='basic_string<targ1'
+ targ1 (str, optional): The first template argument. Defaults to None.
Checks if a specialization of the class template 'template' is the same type
as the typedef 'name', and prints it as 'name' instead.
e.g. if an instantiation of std::basic_istream<C, T> is the same type as
std::istream then print it as std::istream.
+
+ If targ1 is provided (not None), match only template specializations with
+ this type as the first template argument, e.g. if template='basic_string'
+ and targ1='char' then only match 'basic_string<char,...>' and not
+ 'basic_string<wchar_t,...>'. This rejects non-matching specializations
+ more quickly, without needing to do GDB type lookups.
"""
- def __init__(self, template, name, targ1):
+ def __init__(self, template, name, targ1 = None):
self.template = template
self.name = name
self.targ1 = targ1
--
2.38.1
reply other threads:[~2022-11-16 13:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20221116133815.1351836-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).