This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: Improved pretty printing for smart pointers


>>>>> "Michael" == Michael Marte <informarte@freenet.de> writes:

Michael> I took your advice into account, see the attached patch.
Michael> Notice that I also improved pretty printing for weak pointers:
Michael> * no children when there are no reference counters
Michael> * no managed value node when use count is zero

I think it looks pretty reasonable overall.

Michael>      def to_string (self):
[...]
Michael> +        refCounts = self.val['_M_refcount']['_M_pi']
Michael> +        if refCounts != 0:
Michael> +            useCount = refCounts['_M_use_count']
Michael> +            weakCount = refCounts['_M_weak_count']
Michael> +            if useCount == 0:
Michael> +                state = 'expired, weak count = %d' % weakCount
Michael>              else:
Michael> -                state = 'count %d, weak %d' % (usecount, weakcount - 1)
Michael> -        return '%s (%s) %s' % (self.typename, state, self.val['_M_ptr'])
Michael> +                state = 'use count = %d, weak count = %d' % (useCount, weakCount)
Michael> +        managedValue = self.val['_M_ptr']
Michael> +        return '%s<%s> (%s) to %s' % (self.typename, str(managedValue.type.target()), state, managedValue)

This seems to duplicate some data from 'children' in 'to_string'.
That seems like it would give ugly output.

Does it pass the test suite?
If so, it seems like perhaps a new test would be warranted.

You'll need a copyright assignment if you don't have one already.

It needs a ChangeLog entry.

Tom


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