From 032250f87905e26741f5a9de88980b3d73581214 Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Wed, 20 Jul 2022 16:27:01 +0200 Subject: [PATCH 05/12] generate_packets.py: move packet_functional_capability generation into PacketsDefinition See osdn#45170 Signed-off-by: Alina Lenk --- common/generate_packets.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/generate_packets.py b/common/generate_packets.py index 4ee349d9ff..bbc1ef55c1 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -2362,14 +2362,14 @@ class PacketsDefinition(typing.Iterable[Packet]): """Set of all capabilities affecting the defined packets""" return set().union(*(p.all_caps for p in self)) - -# Returns a code fragment which is the implementation of the -# packet_functional_capability string. -def get_packet_functional_capability(packets: PacketsDefinition) -> str: - return """\ + @property + def code_packet_functional_capability(self) -> str: + """Code fragment defining the packet_functional_capability string""" + return """\ const char *const packet_functional_capability = "%s"; -""" % " ".join(sorted(packets.all_caps)) +""" % " ".join(sorted(self.all_caps)) + # Returns a code fragment which is the implementation of the # delta_stats_report() function. @@ -2713,7 +2713,7 @@ def write_common_impl(path: "str | Path | None", packets: PacketsDefinition): #include "packets.h" """) - output_c.write(get_packet_functional_capability(packets)) + output_c.write(packets.code_packet_functional_capability) output_c.write("""\ #ifdef FREECIV_DELTA_PROTOCOL -- 2.34.1