From e176804259c249c88ff25513a723ada81bc68c84 Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Wed, 20 Jul 2022 16:33:19 +0200 Subject: [PATCH 07/12] generate_packets.py: move delta_stats_reset() generation into PacketsDefinition See osdn#45172 Signed-off-by: Alina Lenk --- common/generate_packets.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/common/generate_packets.py b/common/generate_packets.py index e6c735f96a..a10499ebb6 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -2392,27 +2392,27 @@ void delta_stats_report(void) { ) return intro + body + extro - -# Returns a code fragment which is the implementation of the -# delta_stats_reset() function. -def get_reset(packets: typing.Iterable[Packet]) -> str: - if not generate_stats: return """\ + @property + def code_delta_stats_reset(self) -> str: + """Code fragment implementing the delta_stats_reset() function""" + if not generate_stats: return """\ void delta_stats_reset(void) {} """ - intro = """\ + intro = """\ void delta_stats_reset(void) { """ - extro = """\ + extro = """\ } """ - body = "\n".join( - prefix(" ", packet.get_reset_part()) - for packet in packets - ) - return intro+body+extro + body = "\n".join( + prefix(" ", packet.get_reset_part()) + for packet in self + ) + return intro + body + extro + # Returns a code fragment which is the implementation of the # packet_name() function. @@ -2740,7 +2740,7 @@ static int stats_total_sent; output_c.write(p.get_stats()) # write report() output_c.write(packets.code_delta_stats_report) - output_c.write(get_reset(packets)) + output_c.write(packets.code_delta_stats_reset) output_c.write(get_packet_name(packets)) output_c.write(get_packet_has_game_info_flag(packets)) -- 2.34.1