From patchwork Thu Sep 28 20:02:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1841000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JzPDGvA2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RxPYR5LbDz1yp0 for ; Fri, 29 Sep 2023 06:03:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 614523870F30 for ; Thu, 28 Sep 2023 20:03:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C67CA3861911 for ; Thu, 28 Sep 2023 20:03:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C67CA3861911 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695931386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=g6EAjOoKSNZPIA0RPTDh1n4hQjTct53X/Ji7szvfN28=; b=JzPDGvA2nE0hNM5wUyt7iPMEOPlCuAxZJAw2EkLAd5x0Olv0DkXsf7GD4nOIOYj2YJg3Wb 9FOug/UbkE2HPbq0hMAn7ZBx2vtAqsx766TzeiCT01em0nVBaGZzWXgCg4QchioDpy6kav AtcZ7Tx0IcyOnBKrehkjBVyjxmWVB+0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-670-rSm27DHJPsGZzh1eVcuEnA-1; Thu, 28 Sep 2023 16:03:04 -0400 X-MC-Unique: rSm27DHJPsGZzh1eVcuEnA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AF0621C0653A; Thu, 28 Sep 2023 20:03:03 +0000 (UTC) Received: from localhost (unknown [10.42.28.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11F96167F8; Thu, 28 Sep 2023 20:03:02 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Format Python docstrings according to PEP 357 Date: Thu, 28 Sep 2023 21:02:25 +0100 Message-ID: <20230928200302.2973804-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-linux (GDB 13.2, Python 3.11). Pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py: Format docstrings according to PEP 257. * python/libstdcxx/v6/xmethods.py: Likewise. --- libstdc++-v3/python/libstdcxx/v6/printers.py | 177 ++++++++++--------- libstdc++-v3/python/libstdcxx/v6/xmethods.py | 32 ++-- 2 files changed, 112 insertions(+), 97 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index d60c8003a63..7889235ce1c 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -69,7 +69,7 @@ else: # Python 2 does not provide the datetime.UTC singleton. class UTC(datetime.tzinfo): - """Concrete tzinfo class representing the UTC time zone""" + """Concrete tzinfo class representing the UTC time zone.""" def utcoffset(self, dt): return datetime.timedelta(0) @@ -126,7 +126,7 @@ _versioned_namespace = '__8::' def lookup_templ_spec(templ, *args): """ - Lookup template specialization templ + Lookup template specialization templ. """ t = '{}<{}>'.format(templ, ', '.join([str(a) for a in args])) try: @@ -146,17 +146,23 @@ def lookup_templ_spec(templ, *args): # Use this to find container node types instead of find_type, # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91997 for details. - def lookup_node_type(nodename, containertype): """ - Lookup specialization of template NODENAME corresponding to CONTAINERTYPE. - e.g. if NODENAME is '_List_node' and CONTAINERTYPE is std::list - then return the type std::_List_node. - Returns None if not found. + Lookup specialization of template nodename corresponding to containertype. + + nodename - The name of a class template, as a String + containertype - The container, as a gdb.Type + + Return a gdb.Type for the corresponding specialization of nodename, + or None if the type cannot be found. + + e.g. lookup_node_type('_List_node', gdb.lookup_type('std::list')) + will return a gdb.Type for the type std::_List_node. """ # If nodename is unqualified, assume it's in namespace std. if '::' not in nodename: nodename = 'std::' + nodename + # Use either containertype's value_type or its first template argument. try: valtype = find_type(containertype, 'value_type') except: @@ -214,7 +220,7 @@ def strip_versioned_namespace(typename): def strip_inline_namespaces(type_str): - "Remove known inline namespaces from the canonical name of a type." + """Remove known inline namespaces from the canonical name of a type.""" type_str = strip_versioned_namespace(type_str) type_str = type_str.replace('std::__cxx11::', 'std::') expt_ns = 'std::experimental::' @@ -226,7 +232,7 @@ def strip_inline_namespaces(type_str): def get_template_arg_list(type_obj): - "Return a type's template arguments as a list" + """Return a type's template arguments as a list.""" n = 0 template_args = [] while True: @@ -238,7 +244,7 @@ def get_template_arg_list(type_obj): class SmartPtrIterator(Iterator): - "An iterator for smart pointer types with a single 'child' value" + """An iterator for smart pointer types with a single 'child' value.""" def __init__(self, val): self.val = val @@ -254,7 +260,9 @@ class SmartPtrIterator(Iterator): class SharedPointerPrinter: - "Print a shared_ptr, weak_ptr, atomic, or atomic" + """ + Print a shared_ptr, weak_ptr, atomic, or atomic. + """ def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -292,7 +300,7 @@ class SharedPointerPrinter: def _tuple_impl_get(val): - "Return the tuple element stored in a _Tuple_impl base class." + """Return the tuple element stored in a _Tuple_impl base class.""" bases = val.type.fields() if not bases[-1].is_base_class: raise ValueError( @@ -316,7 +324,7 @@ def _tuple_impl_get(val): def tuple_get(n, val): - "Return the result of std::get(val) on a std::tuple" + """Return the result of std::get(val) on a std::tuple.""" tuple_size = len(get_template_arg_list(val.type)) if n > tuple_size: raise ValueError("Out of range index for std::get on std::tuple") @@ -330,7 +338,7 @@ def tuple_get(n, val): def unique_ptr_get(val): - "Return the result of val.get() on a std::unique_ptr" + """Return the result of val.get() on a std::unique_ptr.""" # std::unique_ptr contains a std::tuple, # either as a direct data member _M_t (the old implementation) # or within a data member of type __uniq_ptr_data. @@ -348,7 +356,7 @@ def unique_ptr_get(val): class UniquePointerPrinter: - "Print a unique_ptr" + """Print a unique_ptr.""" def __init__(self, typename, val): self.val = val @@ -361,12 +369,12 @@ class UniquePointerPrinter: def get_value_from_aligned_membuf(buf, valtype): - """Returns the value held in a __gnu_cxx::__aligned_membuf.""" + """Return the value held in a __gnu_cxx::__aligned_membuf.""" return buf['_M_storage'].address.cast(valtype.pointer()).dereference() def get_value_from_list_node(node): - """Returns the value held in an _List_node<_Val>""" + """Return the value held in an _List_node<_Val>.""" try: member = node.type.fields()[1].name if member == '_M_data': @@ -382,7 +390,7 @@ def get_value_from_list_node(node): class StdListPrinter: - "Print a std::list" + """Print a std::list.""" class _iterator(Iterator): def __init__(self, nodetype, head): @@ -434,14 +442,14 @@ class NodeIteratorPrinter: class StdListIteratorPrinter(NodeIteratorPrinter): - "Print std::list::iterator" + """Print std::list::iterator.""" def __init__(self, typename, val): NodeIteratorPrinter.__init__(self, typename, val, 'list', '_List_node') class StdFwdListIteratorPrinter(NodeIteratorPrinter): - "Print std::forward_list::iterator" + """Print std::forward_list::iterator.""" def __init__(self, typename, val): NodeIteratorPrinter.__init__(self, typename, val, 'forward_list', @@ -449,7 +457,7 @@ class StdFwdListIteratorPrinter(NodeIteratorPrinter): class StdSlistPrinter: - "Print a __gnu_cxx::slist" + """Print a __gnu_cxx::slist.""" class _iterator(Iterator): def __init__(self, nodetype, head): @@ -483,7 +491,7 @@ class StdSlistPrinter: class StdSlistIteratorPrinter: - "Print __gnu_cxx::slist::iterator" + """Print __gnu_cxx::slist::iterator.""" def __init__(self, typename, val): self.val = val @@ -497,7 +505,7 @@ class StdSlistIteratorPrinter: class StdVectorPrinter: - "Print a std::vector" + """Print a std::vector.""" class _iterator(Iterator): def __init__(self, start, finish, bitvec): @@ -569,7 +577,7 @@ class StdVectorPrinter: class StdVectorIteratorPrinter: - "Print std::vector::iterator" + """Print std::vector::iterator.""" def __init__(self, typename, val): self.val = val @@ -581,7 +589,7 @@ class StdVectorIteratorPrinter: class StdBitIteratorPrinter: - "Print std::vector's _Bit_iterator and _Bit_const_iterator" + """Print std::vector's _Bit_iterator and _Bit_const_iterator.""" def __init__(self, typename, val): self.val = val @@ -593,7 +601,7 @@ class StdBitIteratorPrinter: class StdBitReferencePrinter: - "Print std::vector::reference" + """Print std::vector::reference.""" def __init__(self, typename, val): self.val = val @@ -605,7 +613,7 @@ class StdBitReferencePrinter: class StdTuplePrinter: - "Print a std::tuple" + """Print a std::tuple.""" class _iterator(Iterator): @staticmethod @@ -690,7 +698,7 @@ class StdTuplePrinter: class StdStackOrQueuePrinter: - "Print a std::stack or std::queue" + """Print a std::stack or std::queue.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -750,7 +758,7 @@ class RbtreeIterator(Iterator): def get_value_from_Rb_tree_node(node): - """Returns the value held in an _Rb_tree_node<_Val>""" + """Return the value held in an _Rb_tree_node<_Val>.""" try: member = node.type.fields()[1].name if member == '_M_value_field': @@ -770,7 +778,7 @@ def get_value_from_Rb_tree_node(node): class StdRbtreeIteratorPrinter: - "Print std::map::iterator, std::set::iterator, etc." + """Print std::map::iterator, std::set::iterator, etc.""" def __init__(self, typename, val): self.val = val @@ -785,7 +793,7 @@ class StdRbtreeIteratorPrinter: class StdDebugIteratorPrinter: - "Print a debug enabled version of an iterator" + """Print a debug enabled version of an iterator.""" def __init__(self, typename, val): self.val = val @@ -809,7 +817,7 @@ def num_elements(num): class StdMapPrinter: - "Print a std::map or std::multimap" + """Print a std::map or std::multimap.""" # Turn an RbtreeIterator into a pretty-print iterator. class _iter(Iterator): @@ -851,7 +859,7 @@ class StdMapPrinter: class StdSetPrinter: - "Print a std::set or std::multiset" + """Print a std::set or std::multiset.""" # Turn an RbtreeIterator into a pretty-print iterator. class _iter(Iterator): @@ -887,7 +895,7 @@ class StdSetPrinter: class StdBitsetPrinter: - "Print a std::bitset" + """Print a std::bitset.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -934,7 +942,7 @@ class StdBitsetPrinter: class StdDequePrinter: - "Print a std::deque" + """Print a std::deque.""" class _iter(Iterator): def __init__(self, node, start, end, last, buffer_size): @@ -999,7 +1007,7 @@ class StdDequePrinter: class StdDequeIteratorPrinter: - "Print std::deque::iterator" + """Print std::deque::iterator.""" def __init__(self, typename, val): self.val = val @@ -1011,7 +1019,7 @@ class StdDequeIteratorPrinter: class StdStringPrinter: - "Print a std::basic_string of some kind" + """Print a std::basic_string of some kind.""" def __init__(self, typename, val): self.val = val @@ -1045,7 +1053,7 @@ class StdStringPrinter: def access_streambuf_ptrs(streambuf): - "Access the streambuf put area pointers" + """Access the streambuf put area pointers.""" pbase = streambuf['_M_out_beg'] pptr = streambuf['_M_out_cur'] egptr = streambuf['_M_in_end'] @@ -1053,7 +1061,7 @@ def access_streambuf_ptrs(streambuf): class StdStringBufPrinter: - "Print a std::basic_stringbuf" + """Print a std::basic_stringbuf.""" def __init__(self, _, val): self.val = val @@ -1073,7 +1081,7 @@ class StdStringBufPrinter: class StdStringStreamPrinter: - "Print a std::basic_stringstream" + """Print a std::basic_stringstream.""" def __init__(self, typename, val): self.val = val @@ -1153,7 +1161,7 @@ class StdHashtableIterator(Iterator): class Tr1UnorderedSetPrinter: - "Print a std::unordered_set or tr1::unordered_set" + """Print a std::unordered_set or tr1::unordered_set.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -1180,7 +1188,7 @@ class Tr1UnorderedSetPrinter: class Tr1UnorderedMapPrinter: - "Print a std::unordered_map or tr1::unordered_map" + """Print a std::unordered_map or tr1::unordered_map.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -1227,7 +1235,7 @@ class Tr1UnorderedMapPrinter: class StdForwardListPrinter: - "Print a std::forward_list" + """Print a std::forward_list.""" class _iterator(Iterator): def __init__(self, nodetype, head): @@ -1264,7 +1272,7 @@ class StdForwardListPrinter: class SingleObjContainerPrinter(object): - "Base class for printers of containers of single objects" + """Base class for printers of containers of single objects.""" def __init__(self, val, viz, hint=None): self.contained_value = val @@ -1272,7 +1280,7 @@ class SingleObjContainerPrinter(object): self.hint = hint def _recognize(self, type): - """Return TYPE as a string after applying type printers""" + """Return type as a string after applying type printers.""" global _use_type_printing if not _use_type_printing: return str(type) @@ -1308,8 +1316,8 @@ class SingleObjContainerPrinter(object): def function_pointer_to_name(f): - "Find the name of the function referred to by the gdb.Value f, " - " which should contain a function pointer from the program." + """Find the name of the function referred to by the gdb.Value f, + which should contain a function pointer from the program.""" # Turn the function pointer into an actual address. # This is needed to unpack ppc64 function descriptors. @@ -1332,7 +1340,7 @@ def function_pointer_to_name(f): class StdExpAnyPrinter(SingleObjContainerPrinter): - "Print a std::any or std::experimental::any" + """Print a std::any or std::experimental::any.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -1413,7 +1421,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): class StdExpOptionalPrinter(SingleObjContainerPrinter): - "Print a std::optional or std::experimental::optional" + """Print a std::optional or std::experimental::optional.""" def __init__(self, typename, val): valtype = self._recognize(val.type.template_argument(0)) @@ -1448,7 +1456,7 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter): class StdVariantPrinter(SingleObjContainerPrinter): - "Print a std::variant" + """Print a std::variant.""" def __init__(self, typename, val): alternatives = get_template_arg_list(val.type) @@ -1477,7 +1485,7 @@ class StdVariantPrinter(SingleObjContainerPrinter): class StdNodeHandlePrinter(SingleObjContainerPrinter): - "Print a container node handle" + """Print a container node handle.""" def __init__(self, typename, val): self.value_type = val.type.template_argument(1) @@ -1521,7 +1529,9 @@ class StdNodeHandlePrinter(SingleObjContainerPrinter): class StdExpStringViewPrinter: - "Print a std::basic_string_view or std::experimental::basic_string_view" + """ + Print a std::basic_string_view or std::experimental::basic_string_view + """ def __init__(self, typename, val): self.val = val @@ -1538,7 +1548,7 @@ class StdExpStringViewPrinter: class StdExpPathPrinter: - "Print a std::experimental::filesystem::path" + """Print a std::experimental::filesystem::path.""" def __init__(self, typename, val): self.val = val @@ -1591,7 +1601,7 @@ class StdExpPathPrinter: class StdPathPrinter: - "Print a std::filesystem::path" + """Print a std::filesystem::path.""" def __init__(self, typename, val): self.val = val @@ -1664,13 +1674,13 @@ class StdPathPrinter: class StdPairPrinter: - "Print a std::pair object, with 'first' and 'second' as children" + """Print a std::pair object, with 'first' and 'second' as children.""" def __init__(self, typename, val): self.val = val class _iter(Iterator): - "An iterator for std::pair types. Returns 'first' then 'second'." + """An iterator for std::pair types. Returns 'first' then 'second'.""" def __init__(self, val): self.val = val @@ -1697,7 +1707,7 @@ class StdPairPrinter: class StdCmpCatPrinter: - "Print a comparison category object" + """Print a comparison category object.""" def __init__(self, typename, val): self.typename = typename[typename.rfind(':')+1:] @@ -1713,7 +1723,7 @@ class StdCmpCatPrinter: class StdErrorCodePrinter: - "Print a std::error_code or std::error_condition" + """Print a std::error_code or std::error_condition.""" _system_is_posix = None # Whether std::system_category() use errno values. @@ -1803,7 +1813,9 @@ class StdErrorCodePrinter: @staticmethod def _unqualified_name(name): - "Strip any nested-name-specifier from NAME to give an unqualified name" + """ + Strip any nested-name-specifier from name to give an unqualified name. + """ return name.split('::')[-1] def to_string(self): @@ -1833,7 +1845,7 @@ class StdErrorCodePrinter: class StdRegexStatePrinter: - "Print a state node in the NFA for a std::regex" + """Print a state node in the NFA for a std::regex.""" def __init__(self, typename, val): self.val = val @@ -1862,7 +1874,7 @@ class StdRegexStatePrinter: class StdSpanPrinter: - "Print a std::span" + """Print a std::span.""" class iterator(Iterator): def __init__(self, begin, size): @@ -1900,7 +1912,7 @@ class StdSpanPrinter: class StdInitializerListPrinter: - "Print a std::initializer_list" + """Print a std::initializer_list.""" def __init__(self, typename, val): self.typename = typename @@ -1918,7 +1930,7 @@ class StdInitializerListPrinter: class StdAtomicPrinter: - "Print a std:atomic" + """Print a std:atomic.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -1953,7 +1965,7 @@ class StdAtomicPrinter: class StdFormatArgsPrinter: - "Print a std::basic_format_args" + """Print a std::basic_format_args.""" # TODO: add printer for basic_format_arg and print out children. # TODO: add printer for __format::_ArgStore. @@ -1988,7 +2000,7 @@ def std_ratio_t_tuple(ratio_type): class StdChronoDurationPrinter: - "Print a std::chrono::duration" + """Print a std::chrono::duration.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -2030,7 +2042,7 @@ class StdChronoDurationPrinter: class StdChronoTimePointPrinter: - "Print a std::chrono::time_point" + """Print a std::chrono::time_point.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -2077,7 +2089,7 @@ class StdChronoTimePointPrinter: class StdChronoZonedTimePrinter: - "Print a std::chrono::zoned_time" + """Print a std::chrono::zoned_time.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -2099,7 +2111,7 @@ weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', class StdChronoCalendarPrinter: - "Print a std::chrono::day, std::chrono::month, std::chrono::year etc." + """Print a std::chrono::day, std::chrono::month, std::chrono::year etc.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -2162,7 +2174,7 @@ class StdChronoCalendarPrinter: class StdChronoTimeZonePrinter: - "Print a chrono::time_zone or chrono::time_zone_link" + """Print a chrono::time_zone or chrono::time_zone_link.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -2176,7 +2188,7 @@ class StdChronoTimeZonePrinter: class StdChronoLeapSecondPrinter: - "Print a chrono::leap_second" + """Print a chrono::leap_second.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -2189,7 +2201,7 @@ class StdChronoLeapSecondPrinter: class StdChronoTzdbPrinter: - "Print a chrono::tzdb" + """Print a chrono::tzdb.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -2200,7 +2212,7 @@ class StdChronoTzdbPrinter: class StdChronoTimeZoneRulePrinter: - "Print a chrono::time_zone rule" + """Print a chrono::time_zone rule.""" def __init__(self, typename, val): self.typename = strip_versioned_namespace(typename) @@ -2234,7 +2246,7 @@ class StdChronoTimeZoneRulePrinter: class StdLocalePrinter: - "Print a std::locale" + """Print a std::locale.""" def __init__(self, typename, val): self.val = val @@ -2372,14 +2384,14 @@ libstdcxx_printer = None class TemplateTypePrinter(object): - r""" + """ A type printer for class templates with default template arguments. Recognizes specializations of class templates and prints them without any template arguments that use a default template argument. Type printers are recursively applied to the template arguments. - e.g. replace "std::vector >" with "std::vector". + e.g. replace 'std::vector >' with 'std::vector'. """ def __init__(self, name, defargs): @@ -2388,7 +2400,7 @@ class TemplateTypePrinter(object): self.enabled = True class _recognizer(object): - "The recognizer class for TemplateTypePrinter." + """The recognizer class for TemplateTypePrinter.""" def __init__(self, name, defargs): self.name = name @@ -2468,12 +2480,12 @@ class TemplateTypePrinter(object): return str(type_obj) def instantiate(self): - "Return a recognizer object for this type printer." + """Return a recognizer object for this type printer.""" return self._recognizer(self.name, self.defargs) def add_one_template_type_printer(obj, name, defargs): - r""" + """ Add a type printer for a class template with default template arguments. Args: @@ -2487,7 +2499,6 @@ def add_one_template_type_printer(obj, name, defargs): { 2: 'std::hash<{0}>', 3: 'std::equal_to<{0}>', 4: 'std::allocator >' } - """ printer = TemplateTypePrinter('std::'+name, defargs) gdb.types.register_type_printer(obj, printer) @@ -2511,7 +2522,7 @@ def add_one_template_type_printer(obj, name, defargs): class FilteringTypePrinter(object): - r""" + """ A type printer that uses typedef names for common template specializations. Args: @@ -2539,7 +2550,7 @@ class FilteringTypePrinter(object): self.enabled = True class _recognizer(object): - "The recognizer class for FilteringTypePrinter." + """The recognizer class for FilteringTypePrinter.""" def __init__(self, template, name, targ1): self.template = template @@ -2583,7 +2594,7 @@ class FilteringTypePrinter(object): return None def instantiate(self): - "Return a recognizer object for this type printer." + """Return a recognizer object for this type printer.""" return self._recognizer(self.template, self.name, self.targ1) @@ -2708,7 +2719,7 @@ def register_type_printers(obj): def register_libstdcxx_printers(obj): - "Register libstdc++ pretty-printers with objfile Obj." + """Register libstdc++ pretty-printers with objfile Obj.""" global _use_gdb_pp global libstdcxx_printer diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py index 025b1b86ed0..ef0a6e3cef3 100644 --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py @@ -607,7 +607,9 @@ class AssociativeContainerMethodsMatcher(gdb.xmethod.XMethodMatcher): class UniquePtrGetWorker(gdb.xmethod.XMethodWorker): - "Implements std::unique_ptr::get() and std::unique_ptr::operator->()" + """ + Implement std::unique_ptr::get() and std::unique_ptr::operator->(). + """ def __init__(self, elem_type): self._is_array = elem_type.code == gdb.TYPE_CODE_ARRAY @@ -623,7 +625,7 @@ class UniquePtrGetWorker(gdb.xmethod.XMethodWorker): return self._elem_type.pointer() def _supports(self, method_name): - "operator-> is not supported for unique_ptr" + # operator-> is not supported for unique_ptr return method_name == 'get' or not self._is_array def __call__(self, obj): @@ -647,7 +649,7 @@ class UniquePtrGetWorker(gdb.xmethod.XMethodWorker): class UniquePtrDerefWorker(UniquePtrGetWorker): - "Implements std::unique_ptr::operator*()" + """Implement std::unique_ptr::operator*().""" def __init__(self, elem_type): UniquePtrGetWorker.__init__(self, elem_type) @@ -656,7 +658,7 @@ class UniquePtrDerefWorker(UniquePtrGetWorker): return self._elem_type def _supports(self, method_name): - "operator* is not supported for unique_ptr" + # operator* is not supported for unique_ptr return not self._is_array def __call__(self, obj): @@ -664,7 +666,7 @@ class UniquePtrDerefWorker(UniquePtrGetWorker): class UniquePtrSubscriptWorker(UniquePtrGetWorker): - "Implements std::unique_ptr::operator[](size_t)" + """Implement std::unique_ptr::operator[](size_t).""" def __init__(self, elem_type): UniquePtrGetWorker.__init__(self, elem_type) @@ -676,7 +678,7 @@ class UniquePtrSubscriptWorker(UniquePtrGetWorker): return self._elem_type def _supports(self, method_name): - "operator[] is only supported for unique_ptr" + # operator[] is only supported for unique_ptr return self._is_array def __call__(self, obj, index): @@ -710,7 +712,9 @@ class UniquePtrMethodsMatcher(gdb.xmethod.XMethodMatcher): class SharedPtrGetWorker(gdb.xmethod.XMethodWorker): - "Implements std::shared_ptr::get() and std::shared_ptr::operator->()" + """ + Implements std::shared_ptr::get() and std::shared_ptr::operator->(). + """ def __init__(self, elem_type): self._is_array = elem_type.code == gdb.TYPE_CODE_ARRAY @@ -726,7 +730,7 @@ class SharedPtrGetWorker(gdb.xmethod.XMethodWorker): return self._elem_type.pointer() def _supports(self, method_name): - "operator-> is not supported for shared_ptr" + # operator-> is not supported for shared_ptr return method_name == 'get' or not self._is_array def __call__(self, obj): @@ -734,7 +738,7 @@ class SharedPtrGetWorker(gdb.xmethod.XMethodWorker): class SharedPtrDerefWorker(SharedPtrGetWorker): - "Implements std::shared_ptr::operator*()" + """Implement std::shared_ptr::operator*().""" def __init__(self, elem_type): SharedPtrGetWorker.__init__(self, elem_type) @@ -743,7 +747,7 @@ class SharedPtrDerefWorker(SharedPtrGetWorker): return self._elem_type def _supports(self, method_name): - "operator* is not supported for shared_ptr" + # operator* is not supported for shared_ptr return not self._is_array def __call__(self, obj): @@ -751,7 +755,7 @@ class SharedPtrDerefWorker(SharedPtrGetWorker): class SharedPtrSubscriptWorker(SharedPtrGetWorker): - "Implements std::shared_ptr::operator[](size_t)" + """Implement std::shared_ptr::operator[](size_t).""" def __init__(self, elem_type): SharedPtrGetWorker.__init__(self, elem_type) @@ -763,7 +767,7 @@ class SharedPtrSubscriptWorker(SharedPtrGetWorker): return self._elem_type def _supports(self, method_name): - "operator[] is only supported for shared_ptr" + # operator[] is only supported for shared_ptr return self._is_array def __call__(self, obj, index): @@ -776,7 +780,7 @@ class SharedPtrSubscriptWorker(SharedPtrGetWorker): class SharedPtrUseCountWorker(gdb.xmethod.XMethodWorker): - "Implements std::shared_ptr::use_count()" + """Implement std::shared_ptr::use_count().""" def __init__(self, elem_type): pass @@ -796,7 +800,7 @@ class SharedPtrUseCountWorker(gdb.xmethod.XMethodWorker): class SharedPtrUniqueWorker(SharedPtrUseCountWorker): - "Implements std::shared_ptr::unique()" + """Implement std::shared_ptr::unique().""" def __init__(self, elem_type): SharedPtrUseCountWorker.__init__(self, elem_type)