From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id AE822395A073; Wed, 16 Nov 2022 13:37:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE822395A073 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668605871; bh=vi0BUxq6aJLrqZVUD0YUyYJ6pabSyWbjwyTx3qFGP2E=; h=From:To:Subject:Date:From; b=bNamWDY1uZC5KYmnegB6JypeMHRQxPPypZeIKVTUygSs9ECs0fcRZfqeHWF7FakO6 cWraX8SGYlMYKwBEClU9f+upIeOGYQrg0Vs3oDsqbikzenA2HOrJsw6xP4yNzsn1Ys Qqs95InvSejsihK9qqRR6fEWvScVxLzPDo8Vt1q4= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-4090] libstdc++: Improve comments on pretty printer code X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 6f83861cc1c4d09425aa6539877bfa50ef90f183 X-Git-Newrev: 922816220210c53eb889733b5832cbd39353ff8c Message-Id: <20221116133751.AE822395A073@sourceware.org> Date: Wed, 16 Nov 2022 13:37:51 +0000 (GMT) List-Id: https://gcc.gnu.org/g:922816220210c53eb889733b5832cbd39353ff8c commit r13-4090-g922816220210c53eb889733b5832cbd39353ff8c Author: Jonathan Wakely Date: Wed Nov 16 11:02:42 2022 +0000 libstdc++: Improve comments on pretty printer code 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. Diff: --- 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 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' and not + 'basic_string'. 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