Add support for protobuf Sint32 type
This commit is contained in:
parent
5e7d2833af
commit
4916393139
|
@ -54,6 +54,8 @@ async def dump_uvarint(writer, n):
|
||||||
class UVarintType:
|
class UVarintType:
|
||||||
WIRE_TYPE = 0
|
WIRE_TYPE = 0
|
||||||
|
|
||||||
|
class Sint32Type:
|
||||||
|
WIRE_TYPE = 0
|
||||||
|
|
||||||
class BoolType:
|
class BoolType:
|
||||||
WIRE_TYPE = 0
|
WIRE_TYPE = 0
|
||||||
|
@ -145,6 +147,8 @@ async def load_message(reader, msg_type):
|
||||||
|
|
||||||
if ftype is UVarintType:
|
if ftype is UVarintType:
|
||||||
fvalue = ivalue
|
fvalue = ivalue
|
||||||
|
elif ftype is Sint32Type:
|
||||||
|
fvalue = (ivalue >> 1) ^ ((ivalue << 31) & 0xffffffff)
|
||||||
elif ftype is BoolType:
|
elif ftype is BoolType:
|
||||||
fvalue = bool(ivalue)
|
fvalue = bool(ivalue)
|
||||||
elif ftype is BytesType:
|
elif ftype is BytesType:
|
||||||
|
@ -201,6 +205,9 @@ async def dump_message(writer, msg):
|
||||||
if ftype is UVarintType:
|
if ftype is UVarintType:
|
||||||
await dump_uvarint(writer, svalue)
|
await dump_uvarint(writer, svalue)
|
||||||
|
|
||||||
|
elif ftype is Sint32Type:
|
||||||
|
await dump_uvarint(writer, ((svalue << 1) & 0xffffffff) ^ (svalue >> 31))
|
||||||
|
|
||||||
elif ftype is BoolType:
|
elif ftype is BoolType:
|
||||||
await dump_uvarint(writer, int(svalue))
|
await dump_uvarint(writer, int(svalue))
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,9 @@ def process_type(t, cls, msg_id, indexfile, is_upy):
|
||||||
# TYPE_ENUM = 14
|
# TYPE_ENUM = 14
|
||||||
type = 'p.UVarintType'
|
type = 'p.UVarintType'
|
||||||
|
|
||||||
elif v.type in (17, 18):
|
elif v.type in (17,):
|
||||||
# TYPE_SINT64 = 18
|
|
||||||
# TYPE_SINT32 = 17
|
# TYPE_SINT32 = 17
|
||||||
type = 'p.VarintType'
|
type = 'p.Sint32Type'
|
||||||
|
|
||||||
elif v.type == 9:
|
elif v.type == 9:
|
||||||
# TYPE_STRING = 9
|
# TYPE_STRING = 9
|
||||||
|
|
Loading…
Reference in New Issue