Freeciv-3.3: generate_packets.PacketsDefinition Class Reference

Freeciv-3.3

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_packet_destroy (self)
str | code_enum_packet (self)
Public Member Functions inherited from generate_packets.Packet
str | name (self)
bool | no_packet (self)
str | send_params (self)
str | send_args (self)
str | dsend_params (self)
str | send_prototype (self)
str | lsend_prototype (self)
str | dsend_prototype (self)
str | dlsend_prototype (self)
bool | complex (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_init (self)
str | get_free_destroy (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
| reset_packets
| 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
| 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*$")
ScriptConfig | cfg
TypeRegistry | type_registry
str | types : "dict[str, RawFieldType]"
str | packets : "list[Packet]"
str | packets_by_type : "dict[str, Packet]"
str | packets_by_number : "dict[int, Packet]"
str | packets_by_dirs : "dict[Directions, list[Packet]]"
Static Public Attributes inherited from generate_packets.Packet
| RESET_PATTERN = re.compile(r"^reset\((.*)\‍)$")
ScriptConfig | cfg
str | type
int | type_number
str | reset_packets : "list[str]"
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
Directions | dirs
str | all_fields : "list[Field]"
str | fields : "list[Field]"
str | variants : "list[Variant]"

## Protected Member Functions

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

## Detailed Description

    Represents an entire packets definition file

Definition at line 3674 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 3856 of file generate_packets.py.

## Member Function Documentation

## ◆ __iter__()

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

Definition at line 3868 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 3763 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 3886 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 3898 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 3919 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 4205 of file generate_packets.py.

## ◆ code_packet_destroy()

str generate_packets.PacketsDefinition.code_packet_destroy | ( |  | self | ) |

    Code fragment implementing the packet_destroy() function

Definition at line 4178 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 3891 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 4050 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 3994 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 3967 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 3940 of file generate_packets.py.

## ◆ define_type()

generate_packets.PacketsDefinition.define_type | ( |  | self,
|  | str | alias,
|  | str | meaning
| ) |  |

    Define a type alias

Definition at line 3850 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 3871 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 3803 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 3799 of file generate_packets.py.

## ◆ resolve_type()

RawFieldType generate_packets.PacketsDefinition.resolve_type | ( |  | self,
|  | str | type_text
| ) |  |

    Resolve the given type

Definition at line 3844 of file generate_packets.py.

## Field Documentation

## ◆ all_caps

generate_packets.PacketsDefinition.all_caps

Definition at line 4001 of file generate_packets.py.

## ◆ cfg [1/2]

ScriptConfig generate_packets.PacketsDefinition.cfg

static

Definition at line 3740 of file generate_packets.py.

## ◆ cfg [2/2]

generate_packets.PacketsDefinition.cfg

Definition at line 3828 of file generate_packets.py.

## ◆ COMMENT_END_PATTERN

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

static

Definition at line 3704 of file generate_packets.py.

## ◆ COMMENT_START_PATTERN

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

static

Definition at line 3677 of file generate_packets.py.

## ◆ PACKET_END_PATTERN

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

static

Definition at line 3737 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 3729 of file generate_packets.py.

## ◆ packets [1/2]

str generate_packets.PacketsDefinition.packets : "list[Packet]"

static

Definition at line 3749 of file generate_packets.py.

## ◆ packets [2/2]

generate_packets.PacketsDefinition.packets

Definition at line 3860 of file generate_packets.py.

## ◆ packets_by_dirs [1/2]

str generate_packets.PacketsDefinition.packets_by_dirs : "dict[Directions, list[Packet]]"

static

Definition at line 3758 of file generate_packets.py.

## ◆ packets_by_dirs [2/2]

generate_packets.PacketsDefinition.packets_by_dirs

Definition at line 3863 of file generate_packets.py.

## ◆ packets_by_number [1/2]

str generate_packets.PacketsDefinition.packets_by_number : "dict[int, Packet]"

static

Definition at line 3755 of file generate_packets.py.

## ◆ packets_by_number [2/2]

generate_packets.PacketsDefinition.packets_by_number

Definition at line 3862 of file generate_packets.py.

## ◆ packets_by_type [1/2]

str generate_packets.PacketsDefinition.packets_by_type : "dict[str, Packet]"

static

Definition at line 3752 of file generate_packets.py.

## ◆ packets_by_type [2/2]

generate_packets.PacketsDefinition.packets_by_type

Definition at line 3861 of file generate_packets.py.

## ◆ resolve_type

generate_packets.PacketsDefinition.resolve_type

Definition at line 3833 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 3722 of file generate_packets.py.

## ◆ type_registry [1/2]

TypeRegistry generate_packets.PacketsDefinition.type_registry

static

Definition at line 3743 of file generate_packets.py.

## ◆ type_registry [2/2]

generate_packets.PacketsDefinition.type_registry

Definition at line 3858 of file generate_packets.py.

## ◆ types [1/2]

str generate_packets.PacketsDefinition.types : "dict[str, RawFieldType]"

static

Definition at line 3746 of file generate_packets.py.

## ◆ types [2/2]

generate_packets.PacketsDefinition.types

Definition at line 3859 of file generate_packets.py.