(obj)
| 394 | |
| 395 | @staticmethod |
| 396 | def encode(obj): |
| 397 | r = bytearray(0) |
| 398 | if obj.value == 0: |
| 399 | return bytes(r) |
| 400 | neg = obj.value < 0 |
| 401 | absvalue = -obj.value if neg else obj.value |
| 402 | while (absvalue): |
| 403 | r.append(absvalue & 0xff) |
| 404 | absvalue >>= 8 |
| 405 | if r[-1] & 0x80: |
| 406 | r.append(0x80 if neg else 0) |
| 407 | elif neg: |
| 408 | r[-1] |= 0x80 |
| 409 | return bytes([len(r)]) + r |
| 410 | |
| 411 | @staticmethod |
| 412 | def decode(vch): |
no outgoing calls