1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00

"TYPE = %d" => "t.type = %d"

This commit is contained in:
slush0 2016-05-12 16:05:33 +02:00 committed by Pavol Rusnak
parent 20e426e846
commit 3f9020ccf4
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -5,11 +5,14 @@ import os
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",]
out = ["t = p.MessageType()", ]
if msg_id is not None:
out.append("t.type = const(%d)" % msg_id)
print(" * type %s" % t)
TYPE_STRING = 9
@ -113,12 +116,10 @@ def process_module(mod, genpath):
msg_types = __import__('pb2', globals(), locals(), ['messages_pb2', ]).messages_pb2.MessageType.items()
for t, cls in types.iteritems():
out = process_type(t, cls)
# Find message type for given class
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)