| 1519 | |
| 1520 | |
| 1521 | class DescriptorArray(object): |
| 1522 | def __init__(self, array): |
| 1523 | self.array = array |
| 1524 | |
| 1525 | def Length(self): |
| 1526 | return self.array.Get(0) |
| 1527 | |
| 1528 | def Decode(self, offset, size, value): |
| 1529 | return (value >> offset) & ((1 << size) - 1) |
| 1530 | |
| 1531 | TYPES = [ |
| 1532 | "normal", |
| 1533 | "field", |
| 1534 | "function", |
| 1535 | "callbacks" |
| 1536 | ] |
| 1537 | |
| 1538 | def Type(self, value): |
| 1539 | return DescriptorArray.TYPES[self.Decode(0, 3, value)] |
| 1540 | |
| 1541 | def Attributes(self, value): |
| 1542 | attributes = self.Decode(3, 3, value) |
| 1543 | result = [] |
| 1544 | if (attributes & 0): result += ["ReadOnly"] |
| 1545 | if (attributes & 1): result += ["DontEnum"] |
| 1546 | if (attributes & 2): result += ["DontDelete"] |
| 1547 | return "[" + (",".join(result)) + "]" |
| 1548 | |
| 1549 | def Deleted(self, value): |
| 1550 | return self.Decode(6, 1, value) == 1 |
| 1551 | |
| 1552 | def FieldIndex(self, value): |
| 1553 | return self.Decode(20, 11, value) |
| 1554 | |
| 1555 | def Pointer(self, value): |
| 1556 | return self.Decode(6, 11, value) |
| 1557 | |
| 1558 | def Details(self, di, value): |
| 1559 | return ( |
| 1560 | di, |
| 1561 | self.Type(value), |
| 1562 | self.Attributes(value), |
| 1563 | self.FieldIndex(value), |
| 1564 | self.Pointer(value) |
| 1565 | ) |
| 1566 | |
| 1567 | |
| 1568 | def Print(self, p): |
| 1569 | length = self.Length() |
| 1570 | array = self.array |
| 1571 | |
| 1572 | p.Print("Descriptors(%08x, length=%d)" % (array.address, length)) |
| 1573 | p.Print("[et] %s" % (array.Get(1))) |
| 1574 | |
| 1575 | for di in range(length): |
| 1576 | i = 2 + di * 3 |
| 1577 | p.Print("0x%x" % (array.address + array.MemberOffset(i))) |
| 1578 | p.Print("[%i] name: %s" % (di, array.Get(i + 0))) |
no outgoing calls
no test coverage detected