tools: update protobuf (sync with python-trezor)

This commit is contained in:
Pavol Rusnak 2018-01-30 15:11:09 +01:00
parent 5f9c079f5c
commit b79ea10434
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 22 additions and 0 deletions

View File

@ -53,6 +53,14 @@ class UVarintType:
WIRE_TYPE = 0
class Sint32Type:
WIRE_TYPE = 0
class Sint64Type:
WIRE_TYPE = 0
class BoolType:
WIRE_TYPE = 0
@ -143,6 +151,10 @@ async def load_message(reader, msg_type):
if ftype is UVarintType:
fvalue = ivalue
elif ftype is Sint32Type:
fvalue = (ivalue >> 1) ^ ((ivalue << 31) & 0xffffffff)
elif ftype is Sint64Type:
fvalue = (ivalue >> 1) ^ ((ivalue << 63) & 0xffffffffffffffff)
elif ftype is BoolType:
fvalue = bool(ivalue)
elif ftype is BytesType:
@ -199,6 +211,12 @@ async def dump_message(writer, msg):
if ftype is UVarintType:
await dump_uvarint(writer, svalue)
elif ftype is Sint32Type:
await dump_uvarint(writer, ((svalue << 1) & 0xffffffff) ^ (svalue >> 31))
elif ftype is Sint64Type:
await dump_uvarint(writer, ((svalue << 1) & 0xffffffffffffffff) ^ (svalue >> 63))
elif ftype is BoolType:
await dump_uvarint(writer, int(svalue))

View File

@ -39,6 +39,10 @@ def process_type(t, cls, msg_id, indexfile, is_upy):
# TYPE_SINT32 = 17
type = 'p.Sint32Type'
elif v.type in (18,):
# TYPE_SINT64 = 18
type = 'p.Sint64Type'
elif v.type == 9:
# TYPE_STRING = 9
type = 'p.UnicodeType'