Freeciv-3.2
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Static Public Attributes | Protected Member Functions
generate_packets.PacketsDefinition Class Reference
+ Inheritance diagram for generate_packets.PacketsDefinition:

Public Member Functions

 parse_lines (self, typing.Iterable[str] lines)
 
 parse_clean_lines (self, typing.Iterable[str] lines)
 
RawFieldType resolve_type (self, str type_text)
 
 define_type (self, str alias, str meaning)
 
 __init__ (self, ScriptConfig cfg, "TypeRegistry | None" type_registry=None)
 
typing.Iterator[Packet__iter__ (self)
 
"typing.Generator[tuple[int, Packet, int], None, int]" iter_by_number (self)
 
"set[str]" all_caps (self)
 
str code_packet_functional_capability (self)
 
str code_delta_stats_report (self)
 
str code_delta_stats_reset (self)
 
str code_packet_name (self)
 
str code_packet_has_game_info_flag (self)
 
str code_packet_handlers_fill_initial (self)
 
str code_packet_handlers_fill_capability (self)
 
str code_enum_packet (self)
 
- Public Member Functions inherited from generate_packets.Packet
str name (self)
 
bool no_packet (self)
 
str extra_send_args (self)
 
str extra_send_args2 (self)
 
str extra_send_args3 (self)
 
str send_prototype (self)
 
str lsend_prototype (self)
 
str dsend_prototype (self)
 
str dlsend_prototype (self)
 
str get_struct (self)
 
str get_prototypes (self)
 
str get_stats (self)
 
str get_report_part (self)
 
str get_reset_part (self)
 
str get_send (self)
 
str get_variants (self)
 
str get_lsend (self)
 
str get_dsend (self)
 
str get_dlsend (self)
 

Data Fields

 cfg
 
 resolve_type
 
 type_registry
 
 types
 
 packets
 
 packets_by_type
 
 packets_by_number
 
 packets_by_dirs
 
 all_caps
 
- Data Fields inherited from generate_packets.Packet
 cfg
 
 type
 
 type_number
 
 cancel
 
 is_info
 
 want_dsend
 
 want_lsend
 
 want_force
 
 want_pre_send
 
 want_post_send
 
 want_post_recv
 
 delta
 
 no_handle
 
 handle_via_packet
 
 handle_per_conn
 
 name
 
 dirs
 
 all_fields
 
 fields
 
 variants
 

Static Public Attributes

 COMMENT_START_PATTERN = re.compile(, re.VERBOSE)
 
 COMMENT_END_PATTERN = re.compile(, re.VERBOSE)
 
 TYPE_PATTERN = re.compile(r"^\s*type\s+(\w+)\s*=\s*(.+?)\s*$")
 
 PACKET_HEADER_PATTERN = re.compile(r"^\s*(PACKET_\w+)\s*=\s*(\d+)\s*;\s*(.*?)\s*$")
 
 PACKET_END_PATTERN = re.compile(r"^\s*end\s*$")
 
- Static Public Attributes inherited from generate_packets.Packet
 CANCEL_PATTERN = re.compile(r"^cancel\((.*)\‍)$")
 
str is_info = "no"
 
bool want_dsend = False
 
bool want_lsend = False
 
bool want_force = False
 
bool want_pre_send = False
 
bool want_post_send = False
 
bool want_post_recv = False
 
bool delta = True
 
bool no_handle = False
 
bool handle_via_packet = True
 
bool handle_per_conn = False
 

Protected Member Functions

typing.Iterator[str_clean_lines (cls, typing.Iterable[str] lines)
 

Detailed Description

Represents an entire packets definition file

Definition at line 2914 of file generate_packets.py.

Constructor & Destructor Documentation

◆ __init__()

generate_packets.PacketsDefinition.__init__ (   self,
ScriptConfig  cfg,
"TypeRegistry | None"   type_registry = None 
)

Reimplemented from generate_packets.Packet.

Definition at line 3084 of file generate_packets.py.

Member Function Documentation

◆ __iter__()

typing.Iterator[Packet] generate_packets.PacketsDefinition.__iter__ (   self)

Definition at line 3121 of file generate_packets.py.

◆ _clean_lines()

typing.Iterator[str] generate_packets.PacketsDefinition._clean_lines (   cls,
typing.Iterable[str lines 
)
protected
Strip comments and leading/trailing whitespace from the given
lines. If a block comment starts in one line and ends in another,
the remaining parts are joined together and yielded as one line.

Definition at line 2981 of file generate_packets.py.

◆ all_caps()

"set[str]" generate_packets.PacketsDefinition.all_caps (   self)
Set of all capabilities affecting the defined packets

Reimplemented from generate_packets.Packet.

Definition at line 3139 of file generate_packets.py.

◆ code_delta_stats_report()

str generate_packets.PacketsDefinition.code_delta_stats_report (   self)
Code fragment implementing the delta_stats_report() function

Definition at line 3152 of file generate_packets.py.

◆ code_delta_stats_reset()

str generate_packets.PacketsDefinition.code_delta_stats_reset (   self)
Code fragment implementing the delta_stats_reset() function

Definition at line 3174 of file generate_packets.py.

◆ code_enum_packet()

str generate_packets.PacketsDefinition.code_enum_packet (   self)
Code fragment declaring the packet_type enum

Definition at line 3413 of file generate_packets.py.

◆ code_packet_functional_capability()

str generate_packets.PacketsDefinition.code_packet_functional_capability (   self)
Code fragment defining the packet_functional_capability string

Definition at line 3144 of file generate_packets.py.

◆ code_packet_handlers_fill_capability()

str generate_packets.PacketsDefinition.code_packet_handlers_fill_capability (   self)
Code fragment implementing the packet_handlers_fill_capability()
function

Definition at line 3310 of file generate_packets.py.

◆ code_packet_handlers_fill_initial()

str generate_packets.PacketsDefinition.code_packet_handlers_fill_initial (   self)
Code fragment implementing the packet_handlers_fill_initial()
function

Definition at line 3254 of file generate_packets.py.

◆ code_packet_has_game_info_flag()

str generate_packets.PacketsDefinition.code_packet_has_game_info_flag (   self)
Code fragment implementing the packet_has_game_info_flag()
function

Definition at line 3222 of file generate_packets.py.

◆ code_packet_name()

str generate_packets.PacketsDefinition.code_packet_name (   self)
Code fragment implementing the packet_name() function

Definition at line 3195 of file generate_packets.py.

◆ define_type()

generate_packets.PacketsDefinition.define_type (   self,
str  alias,
str  meaning 
)
Define a type alias

Definition at line 3072 of file generate_packets.py.

◆ iter_by_number()

"typing.Generator[tuple[int, Packet, int], None, int]" generate_packets.PacketsDefinition.iter_by_number (   self)
Yield (number, packet, skipped) tuples in order of packet number.

skipped is how many numbers were skipped since the last packet

Return the maximum packet number (or -1 if there are no packets)
when used with `yield from`.

Definition at line 3124 of file generate_packets.py.

◆ parse_clean_lines()

generate_packets.PacketsDefinition.parse_clean_lines (   self,
typing.Iterable[str lines 
)
Parse the given lines as type and packet definitions. Comments
and blank lines must already be removed beforehand.

Definition at line 3021 of file generate_packets.py.

◆ parse_lines()

generate_packets.PacketsDefinition.parse_lines (   self,
typing.Iterable[str lines 
)
Parse the given lines as type and packet definitions.

Definition at line 3017 of file generate_packets.py.

◆ resolve_type()

RawFieldType generate_packets.PacketsDefinition.resolve_type (   self,
str  type_text 
)
Resolve the given type

Definition at line 3066 of file generate_packets.py.

Field Documentation

◆ all_caps

generate_packets.PacketsDefinition.all_caps

Definition at line 3149 of file generate_packets.py.

◆ cfg

generate_packets.PacketsDefinition.cfg

Definition at line 3050 of file generate_packets.py.

◆ COMMENT_END_PATTERN

generate_packets.PacketsDefinition.COMMENT_END_PATTERN = re.compile(, re.VERBOSE)
static

Definition at line 2944 of file generate_packets.py.

◆ COMMENT_START_PATTERN

generate_packets.PacketsDefinition.COMMENT_START_PATTERN = re.compile(, re.VERBOSE)
static

Definition at line 2917 of file generate_packets.py.

◆ PACKET_END_PATTERN

generate_packets.PacketsDefinition.PACKET_END_PATTERN = re.compile(r"^\s*end\s*$")
static

Definition at line 2977 of file generate_packets.py.

◆ PACKET_HEADER_PATTERN

generate_packets.PacketsDefinition.PACKET_HEADER_PATTERN = re.compile(r"^\s*(PACKET_\w+)\s*=\s*(\d+)\s*;\s*(.*?)\s*$")
static

Definition at line 2969 of file generate_packets.py.

◆ packets

generate_packets.PacketsDefinition.packets

Definition at line 3096 of file generate_packets.py.

◆ packets_by_dirs

generate_packets.PacketsDefinition.packets_by_dirs

Definition at line 3111 of file generate_packets.py.

◆ packets_by_number

generate_packets.PacketsDefinition.packets_by_number

Definition at line 3106 of file generate_packets.py.

◆ packets_by_type

generate_packets.PacketsDefinition.packets_by_type

Definition at line 3101 of file generate_packets.py.

◆ resolve_type

generate_packets.PacketsDefinition.resolve_type

Definition at line 3055 of file generate_packets.py.

◆ TYPE_PATTERN

generate_packets.PacketsDefinition.TYPE_PATTERN = re.compile(r"^\s*type\s+(\w+)\s*=\s*(.+?)\s*$")
static

Definition at line 2962 of file generate_packets.py.

◆ type_registry

generate_packets.PacketsDefinition.type_registry

Definition at line 3087 of file generate_packets.py.

◆ types

generate_packets.PacketsDefinition.types

Definition at line 3091 of file generate_packets.py.