add Sint64 to protobuf

pull/25/head
Pavol Rusnak 6 years ago
parent 11fd72890c
commit 7b844f0379
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -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'

@ -76,6 +76,10 @@ class Sint32Type:
WIRE_TYPE = 0
class Sint64Type:
WIRE_TYPE = 0
class BoolType:
WIRE_TYPE = 0
@ -235,6 +239,8 @@ def load_message(reader, msg_type):
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:
@ -288,6 +294,9 @@ def dump_message(writer, msg):
elif ftype is Sint32Type:
dump_uvarint(writer, ((svalue << 1) & 0xffffffff) ^ (svalue >> 31))
elif ftype is Sint64Type:
dump_uvarint(writer, ((svalue << 1) & 0xffffffffffffffff) ^ (svalue >> 63))
elif ftype is BoolType:
dump_uvarint(writer, int(svalue))

Loading…
Cancel
Save