(self, visited)
| 1473 | _typename = 'PyUnicodeObject' |
| 1474 | |
| 1475 | def proxyval(self, visited): |
| 1476 | compact = self.field('_base') |
| 1477 | ascii = compact['_base'] |
| 1478 | state = ascii['state'] |
| 1479 | is_compact_ascii = (int(state['ascii']) and int(state['compact'])) |
| 1480 | field_length = int(ascii['length']) |
| 1481 | if is_compact_ascii: |
| 1482 | field_str = ascii.address + 1 |
| 1483 | elif int(state['compact']): |
| 1484 | field_str = compact.address + 1 |
| 1485 | else: |
| 1486 | field_str = self.field('data')['any'] |
| 1487 | repr_kind = int(state['kind']) |
| 1488 | if repr_kind == 1: |
| 1489 | field_str = field_str.cast(_type_unsigned_char_ptr()) |
| 1490 | elif repr_kind == 2: |
| 1491 | field_str = field_str.cast(_type_unsigned_short_ptr()) |
| 1492 | elif repr_kind == 4: |
| 1493 | field_str = field_str.cast(_type_unsigned_int_ptr()) |
| 1494 | |
| 1495 | # Gather a list of ints from the code point array; these are either |
| 1496 | # UCS-1, UCS-2 or UCS-4 code points: |
| 1497 | code_points = [int(field_str[i]) for i in safe_range(field_length)] |
| 1498 | |
| 1499 | # Convert the int code points to unicode characters, and generate a |
| 1500 | # local unicode instance. |
| 1501 | result = ''.join(map(chr, code_points)) |
| 1502 | return result |
| 1503 | |
| 1504 | def write_repr(self, out, visited): |
| 1505 | # Write this out as a Python str literal |
no test coverage detected