OLD | NEW |
1 # Copyright (C) 2010, Google Inc. All rights reserved. | 1 # Copyright (C) 2010, Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 318 |
319 class Iterator: | 319 class Iterator: |
320 def __init__(self, start, finish): | 320 def __init__(self, start, finish): |
321 self.item = start | 321 self.item = start |
322 self.finish = finish | 322 self.finish = finish |
323 self.count = 0 | 323 self.count = 0 |
324 | 324 |
325 def __iter__(self): | 325 def __iter__(self): |
326 return self | 326 return self |
327 | 327 |
328 def next(self): | 328 def __next__(self): |
329 if self.item == self.finish: | 329 if self.item == self.finish: |
330 raise StopIteration | 330 raise StopIteration |
331 count = self.count | 331 count = self.count |
332 self.count += 1 | 332 self.count += 1 |
333 element = self.item.dereference() | 333 element = self.item.dereference() |
334 self.item += 1 | 334 self.item += 1 |
335 return ('[%d]' % count, element) | 335 return ('[%d]' % count, element) |
336 | 336 |
| 337 # Python version < 3 compatibility: |
| 338 def next(self): |
| 339 return self.__next__() |
| 340 |
337 def __init__(self, val): | 341 def __init__(self, val): |
338 self.val = val | 342 self.val = val |
339 | 343 |
340 def children(self): | 344 def children(self): |
341 start = self.val['m_buffer'] | 345 start = self.val['m_buffer'] |
342 return self.Iterator(start, start + self.val['m_size']) | 346 return self.Iterator(start, start + self.val['m_size']) |
343 | 347 |
344 def to_string(self): | 348 def to_string(self): |
345 return ('%s of length %d, capacity %d' | 349 return ('%s of length %d, capacity %d' |
346 % ('WTF::Vector', self.val['m_size'], self.val['m_capacity'])) | 350 % ('WTF::Vector', self.val['m_size'], self.val['m_capacity'])) |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 padding = '' | 458 padding = '' |
455 while len(stack) > 0: | 459 while len(stack) > 0: |
456 pair = stack.pop() | 460 pair = stack.pop() |
457 print(padding, pair[1], pair[0]) | 461 print(padding, pair[1], pair[0]) |
458 padding = padding + ' ' | 462 padding = padding + ' ' |
459 else: | 463 else: |
460 print('Sorry: I don\'t know how to deal with %s yet.' % target_type) | 464 print('Sorry: I don\'t know how to deal with %s yet.' % target_type) |
461 | 465 |
462 | 466 |
463 PrintPathToRootCommand() | 467 PrintPathToRootCommand() |
OLD | NEW |