mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-04 03:40:58 +00:00
"TYPE = %d" => "t.type = %d"
This commit is contained in:
parent
20e426e846
commit
3f9020ccf4
11
tools/pb2py
11
tools/pb2py
@ -5,11 +5,14 @@ import os
|
|||||||
|
|
||||||
from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper
|
from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper
|
||||||
|
|
||||||
def process_type(t, cls):
|
def process_type(t, cls, msg_id):
|
||||||
imports = ["from protobuf import protobuf as p",]
|
imports = ["from protobuf import protobuf as p",]
|
||||||
|
|
||||||
out = ["t = p.MessageType()", ]
|
out = ["t = p.MessageType()", ]
|
||||||
|
|
||||||
|
if msg_id is not None:
|
||||||
|
out.append("t.type = const(%d)" % msg_id)
|
||||||
|
|
||||||
print(" * type %s" % t)
|
print(" * type %s" % t)
|
||||||
|
|
||||||
TYPE_STRING = 9
|
TYPE_STRING = 9
|
||||||
@ -113,12 +116,10 @@ def process_module(mod, genpath):
|
|||||||
msg_types = __import__('pb2', globals(), locals(), ['messages_pb2', ]).messages_pb2.MessageType.items()
|
msg_types = __import__('pb2', globals(), locals(), ['messages_pb2', ]).messages_pb2.MessageType.items()
|
||||||
|
|
||||||
for t, cls in types.iteritems():
|
for t, cls in types.iteritems():
|
||||||
out = process_type(t, cls)
|
|
||||||
|
|
||||||
# Find message type for given class
|
# Find message type for given class
|
||||||
msg_id = find_msg_type(msg_types, t)
|
msg_id = find_msg_type(msg_types, t)
|
||||||
if msg_id is not None:
|
|
||||||
out.append('TYPE = const(%d)' % msg_id)
|
out = process_type(t, cls, msg_id)
|
||||||
|
|
||||||
write_to_file(genpath, t, out)
|
write_to_file(genpath, t, out)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user