(obj)
| 477 | |
| 478 | @staticmethod |
| 479 | def encode(obj): |
| 480 | val = obj.value |
| 481 | r = bytearray(0) |
| 482 | if val == 0: |
| 483 | return bytes(r) |
| 484 | neg = val < 0 |
| 485 | absvalue = -val if neg else val |
| 486 | while (absvalue): |
| 487 | r.append(absvalue & 0xff) |
| 488 | absvalue >>= 8 |
| 489 | if r[-1] & 0x80: |
| 490 | r.append(0x80 if neg else 0) |
| 491 | elif neg: |
| 492 | r[-1] |= 0x80 |
| 493 | return bytes([len(r)]) + r |
| 494 | |
| 495 | @staticmethod |
| 496 | def decode(vch): |
no outgoing calls