add Sint64 to protobuf

This commit is contained in:
Pavol Rusnak 2018-01-30 15:04:24 +01:00
parent 11fd72890c
commit 7b844f0379
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 13 additions and 0 deletions

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'

View File

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