Freeciv-3.3: generate_packets.Variant Class Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Static Public Attributes
generate_packets.Variant Class Reference

## Public Member Functions

| __init__ (self, typing.Iterable[str] poscaps, typing.Iterable[str] negcaps, "Packet" packet, int var_number)
ScriptConfig | cfg (self)
bool | gen_stats (self)
"str | None" | log_macro (self)
bool | gen_log (self)
str | packet_name (self)
str | type (self)
bool | no_packet (self)
bool | delta (self)
| want_force (self)
str | is_info (self)
"list[str]" | reset_packets (self)
bool | complex (self)
bool | differ_used (self)
str | condition (self)
int | bits (self)
str | receive_prototype (self)
str | send_prototype (self)
str | fill_send_handler (self)
str | fill_receive_handler (self)
str | get_copy (self, str dest, str src)
str | get_stats (self)
str | get_bitvector (self)
str | get_report_part (self)
str | get_reset_part (self)
str | get_hash (self)
str | get_cmp (self)
str | get_send (self)
str | get_delta_send_header (self, str before_return="")
str | get_delta_send_body (self)
str | get_receive (self)
str | get_delta_receive_body (self)

## Data Fields

| packet
| var_number
| name
| poscaps
| negcaps
| fields
| key_fields
| other_fields
| keys_format
| keys_arg
| is_info

## Static Public Attributes

str | packet : "Packet"
int | var_number
str | name
typing | poscaps .AbstractSet[str]
typing | negcaps .AbstractSet[str]
typing | fields .Sequence[Field]
typing | key_fields .Sequence[Field]
typing | other_fields .Sequence[Field]
str | keys_format
str | keys_arg

## Detailed Description

    Represents one variant of a packet. Packets with add-cap or
    remove-cap fields have different variants for different combinations of
    the relevant optional capabilities.

Definition at line 2429 of file generate_packets.py.

## Constructor & Destructor Documentation

## ◆ __init__()

generate_packets.Variant.__init__ | ( |  | self,
|  | typing.Iterable[str] | poscaps,
|  | typing.Iterable[str] | negcaps,
|  | "Packet" | packet,
|  | int | var_number
| ) |  |

Definition at line 2472 of file generate_packets.py.

## Member Function Documentation

## ◆ bits()

int generate_packets.Variant.bits | ( |  | self | ) |

    The length of the bitvector for this variant.

Definition at line 2613 of file generate_packets.py.

## ◆ cfg()

ScriptConfig generate_packets.Variant.cfg | ( |  | self | ) |

    Configuration used when generating code for this packet
    variant

    See self.packet and Packet.cfg

Definition at line 2497 of file generate_packets.py.

## ◆ complex()

bool generate_packets.Variant.complex | ( |  | self | ) |

    Whether this packet's struct requires special handling for
    initialization, copying, and destruction.

    Note that this is still True even if the complex-typed fields
    of the packet are excluded from this Variant.

Definition at line 2574 of file generate_packets.py.

## ◆ condition()

str generate_packets.Variant.condition | ( |  | self | ) |

    The condition determining whether this variant should be used,
    based on capabilities.

    See get_packet_handlers_fill_capability()

Definition at line 2599 of file generate_packets.py.

## ◆ delta()

bool generate_packets.Variant.delta | ( |  | self | ) |

    Whether this packet can use delta optimization

    See Packet.delta

Definition at line 2548 of file generate_packets.py.

## ◆ differ_used()

bool generate_packets.Variant.differ_used | ( |  | self | ) |

    Whether the send function needs a `differ` boolean.

    See get_send()

Definition at line 2583 of file generate_packets.py.

## ◆ fill_receive_handler()

str generate_packets.Variant.fill_receive_handler | ( |  | self | ) |

    Code to set the receive handler for this variant

    See get_packet_handlers_fill_initial and
    get_packet_handlers_fill_capability

Definition at line 2647 of file generate_packets.py.

## ◆ fill_send_handler()

str generate_packets.Variant.fill_send_handler | ( |  | self | ) |

    Code to set the send handler for this variant

    See get_packet_handlers_fill_initial and
    get_packet_handlers_fill_capability

Definition at line 2628 of file generate_packets.py.

## ◆ gen_log()

bool generate_packets.Variant.gen_log | ( |  | self | ) |

    Whether to generate log calls for this packet variant

    See self.log_macro

Definition at line 2520 of file generate_packets.py.

## ◆ gen_stats()

bool generate_packets.Variant.gen_stats | ( |  | self | ) |

    Whether to generate delta stats code for this packet variant

    See self.cfg and ScriptConfig.gen_stats

Definition at line 2505 of file generate_packets.py.

## ◆ get_bitvector()

str generate_packets.Variant.get_bitvector | ( |  | self | ) |

    Generate the declaration of the fields bitvector type for this
    packet variant

Definition at line 2684 of file generate_packets.py.

## ◆ get_cmp()

str generate_packets.Variant.get_cmp | ( |  | self | ) |

    Generate the key comparison function for this variant

Definition at line 2752 of file generate_packets.py.

## ◆ get_copy()

str generate_packets.Variant.get_copy | ( |  | self,
|  | str | dest,
|  | str | src
| ) |  |

    Generate code deep-copying the fields relevant to this variant
    from *src to *dest

Definition at line 2656 of file generate_packets.py.

## ◆ get_delta_receive_body()

str generate_packets.Variant.get_delta_receive_body | ( |  | self | ) |

    Helper for get_receive(). Generate the part of the receive
    function responsible for recreating the full packet from the
    received delta and the last cached packet.

    Note: This code fragment declares variables. To comply with
    CodingStyle, it should be enclosed in a block {} or #ifdef.

Definition at line 3104 of file generate_packets.py.

## ◆ get_delta_send_body()

str generate_packets.Variant.get_delta_send_body | ( |  | self | ) |

    Helper for get_send(). Generate the part of the send function
    that transmits the delta between the real packet and the last
    cached packet.

    See also get_delta_send_header()

Definition at line 2997 of file generate_packets.py.

## ◆ get_delta_send_header()

str generate_packets.Variant.get_delta_send_header | ( |  | self,
|  | str | before_return = `""`
| ) |  |

    Helper for get_send(). Generate the part of the send function
    that determined which fields differ between the real packet and
    the last cached packet, and possibly discards is-info packets.

Definition at line 2920 of file generate_packets.py.

## ◆ get_hash()

str generate_packets.Variant.get_hash | ( |  | self | ) |

    Generate the key hash function for this variant

Definition at line 2721 of file generate_packets.py.

## ◆ get_receive()

str generate_packets.Variant.get_receive | ( |  | self | ) |

    Generate the receive function for this packet variant

Definition at line 3038 of file generate_packets.py.

## ◆ get_report_part()

str generate_packets.Variant.get_report_part | ( |  | self | ) |

    Generate the part of the delta_stats_report() function specific
    to this packet variant

Definition at line 2691 of file generate_packets.py.

## ◆ get_reset_part()

str generate_packets.Variant.get_reset_part | ( |  | self | ) |

    Generate the part of the delta_stats_reset() function specific
    to this packet variant

Definition at line 2711 of file generate_packets.py.

## ◆ get_send()

str generate_packets.Variant.get_send | ( |  | self | ) |

    Generate the send function for this packet variant

Definition at line 2786 of file generate_packets.py.

## ◆ get_stats()

str generate_packets.Variant.get_stats | ( |  | self | ) |

    Generate the declaration of the delta stats counters associated
    with this packet variant

Definition at line 2668 of file generate_packets.py.

## ◆ is_info()

str generate_packets.Variant.is_info | ( |  | self | ) |

    Whether this is an info or game-info packet

Definition at line 2562 of file generate_packets.py.

## ◆ log_macro()

"str | None" generate_packets.Variant.log_macro | ( |  | self | ) |

    The log macro used to generate log calls for this packet variant,
    or None if no log calls should be generated

    See self.cfg and ScriptConfig.log_macro

Definition at line 2512 of file generate_packets.py.

## ◆ no_packet()

bool generate_packets.Variant.no_packet | ( |  | self | ) |

    Whether the send function should not take/need a packet struct

    See Packet.no_packet

Definition at line 2541 of file generate_packets.py.

## ◆ packet_name()

str generate_packets.Variant.packet_name | ( |  | self | ) |

    Name of the packet this is a variant of

    See Packet.name

Definition at line 2527 of file generate_packets.py.

## ◆ receive_prototype()

str generate_packets.Variant.receive_prototype | ( |  | self | ) |

    The prototype of this variant's receive function

Definition at line 2618 of file generate_packets.py.

## ◆ reset_packets()

"list[str]" generate_packets.Variant.reset_packets | ( |  | self | ) |

    List of packets to reset when sending or receiving this packet

    See Packet.reset_packets

Definition at line 2567 of file generate_packets.py.

## ◆ send_prototype()

str generate_packets.Variant.send_prototype | ( |  | self | ) |

    The prototype of this variant's send function

Definition at line 2623 of file generate_packets.py.

## ◆ type()

str generate_packets.Variant.type | ( |  | self | ) |

    Type (enum constant) of the packet this is a variant of

    See Packet.type

Definition at line 2534 of file generate_packets.py.

## ◆ want_force()

generate_packets.Variant.want_force | ( |  | self | ) |

    Whether send function takes a force_to_send boolean

    See Packet.want_force

Definition at line 2555 of file generate_packets.py.

## Field Documentation

## ◆ fields [1/2]

typing generate_packets.Variant.fields .Sequence[Field]

static

Definition at line 2451 of file generate_packets.py.

## ◆ fields [2/2]

generate_packets.Variant.fields

Definition at line 2480 of file generate_packets.py.

## ◆ is_info

generate_packets.Variant.is_info

Definition at line 2928 of file generate_packets.py.

## ◆ key_fields [1/2]

typing generate_packets.Variant.key_fields .Sequence[Field]

static

Definition at line 2454 of file generate_packets.py.

## ◆ key_fields [2/2]

generate_packets.Variant.key_fields

Definition at line 2485 of file generate_packets.py.

## ◆ keys_arg [1/2]

str generate_packets.Variant.keys_arg

static

Definition at line 2466 of file generate_packets.py.

## ◆ keys_arg [2/2]

generate_packets.Variant.keys_arg

Definition at line 2489 of file generate_packets.py.

## ◆ keys_format [1/2]

str generate_packets.Variant.keys_format

static

Definition at line 2460 of file generate_packets.py.

## ◆ keys_format [2/2]

generate_packets.Variant.keys_format

Definition at line 2488 of file generate_packets.py.

## ◆ name [1/2]

str generate_packets.Variant.name

static

Definition at line 2440 of file generate_packets.py.

## ◆ name [2/2]

generate_packets.Variant.name

Definition at line 2476 of file generate_packets.py.

## ◆ negcaps [1/2]

typing generate_packets.Variant.negcaps .AbstractSet[str]

static

Definition at line 2447 of file generate_packets.py.

## ◆ negcaps [2/2]

generate_packets.Variant.negcaps

Definition at line 2479 of file generate_packets.py.

## ◆ other_fields [1/2]

typing generate_packets.Variant.other_fields .Sequence[Field]

static

Definition at line 2457 of file generate_packets.py.

## ◆ other_fields [2/2]

generate_packets.Variant.other_fields

Definition at line 2486 of file generate_packets.py.

## ◆ packet [1/2]

str generate_packets.Variant.packet : "Packet"

static

Definition at line 2434 of file generate_packets.py.

## ◆ packet [2/2]

generate_packets.Variant.packet

Definition at line 2474 of file generate_packets.py.

## ◆ poscaps [1/2]

typing generate_packets.Variant.poscaps .AbstractSet[str]

static

Definition at line 2443 of file generate_packets.py.

## ◆ poscaps [2/2]

generate_packets.Variant.poscaps

Definition at line 2478 of file generate_packets.py.

## ◆ var_number [1/2]

int generate_packets.Variant.var_number

static

Definition at line 2437 of file generate_packets.py.

## ◆ var_number [2/2]

generate_packets.Variant.var_number

Definition at line 2475 of file generate_packets.py.