Freeciv-3.3
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Static Public Attributes | Protected Attributes | Static Protected Attributes
generate_packets.Location Class Reference

Public Member Functions

 __init__ (self, str name, *"str | None" location=None, int depth=0, "int | None" json_depth=None)
 
"Location" constant (cls, str location, str name="(unknown)")
 
"Location" replace (self, str new_location)
 
"Location" deeper (self, str new_location, int json_step=1)
 
"Location" sub_full (self, int json_step=1)
 
str index (self)
 
"Location" sub (self)
 
str json_subloc (self)
 
str __matmul__ (self, "str | None" packet)
 
str __str__ (self)
 
str __repr__ (self)
 
bool __eq__ (self, other)
 
int __hash__ (self)
 

Data Fields

 name
 
 depth
 
 json_depth
 

Static Public Attributes

str name
 
int depth
 
int json_depth
 

Protected Attributes

 _location
 
 _INDICES
 
 _PACKET
 

Static Protected Attributes

str _PACKET = "#error gen_packet$"
 
str _INDICES = "ijk"
 
str _location
 

Detailed Description

Roughly represents a location in memory for the generated code;
outside of recursive field types like arrays, this will usually just be
a field of a packet, but it serves to concisely handle the recursion.

Definition at line 345 of file generate_packets.py.

Constructor & Destructor Documentation

◆ __init__()

generate_packets.Location.__init__ (   self,
str  name,
*"str | None"   location = None,
int   depth = 0,
"int | None"   json_depth = None 
)

Definition at line 367 of file generate_packets.py.

Member Function Documentation

◆ __eq__()

bool generate_packets.Location.__eq__ (   self,
  other 
)

Definition at line 440 of file generate_packets.py.

◆ __hash__()

int generate_packets.Location.__hash__ (   self)

Definition at line 452 of file generate_packets.py.

◆ __matmul__()

str generate_packets.Location.__matmul__ (   self,
"str | None"  packet 
)
self @ packet
Code fragment of this location in the given packet, or in local
variables if packet is None

Definition at line 427 of file generate_packets.py.

◆ __repr__()

str generate_packets.Location.__repr__ (   self)

Definition at line 437 of file generate_packets.py.

◆ __str__()

str generate_packets.Location.__str__ (   self)

Definition at line 434 of file generate_packets.py.

◆ constant()

"Location" generate_packets.Location.constant (   cls,
str  location,
str   name = "(unknown)" 
)
Construct a Location not dependent on the packet

Definition at line 376 of file generate_packets.py.

◆ deeper()

"Location" generate_packets.Location.deeper (   self,
str  new_location,
int   json_step = 1 
)
Return the given string as a new Location with the same name as
self and incremented depth

Definition at line 391 of file generate_packets.py.

◆ index()

str generate_packets.Location.index (   self)
The index name for the current depth

Definition at line 407 of file generate_packets.py.

◆ json_subloc()

str generate_packets.Location.json_subloc (   self)
The plocation (JSON field address) to the sub-location
of this location's corresponding field address

Definition at line 422 of file generate_packets.py.

◆ replace()

"Location" generate_packets.Location.replace (   self,
str  new_location 
)
Return the given string as a new Location with the same metadata
as self

Definition at line 381 of file generate_packets.py.

◆ sub()

"Location" generate_packets.Location.sub (   self)
A location one level deeper with the current index subscript
added to the end.

`field` ~> `field[i]` ~> `field[i][j]` etc.

Definition at line 414 of file generate_packets.py.

◆ sub_full()

"Location" generate_packets.Location.sub_full (   self,
int   json_step = 1 
)
Like self.sub, but with the option to step the JSON nesting
depth by a different amount.

Definition at line 401 of file generate_packets.py.

Field Documentation

◆ _INDICES [1/2]

str generate_packets.Location._INDICES = "ijk"
staticprotected

Definition at line 353 of file generate_packets.py.

◆ _INDICES [2/2]

generate_packets.Location._INDICES
protected

Definition at line 409 of file generate_packets.py.

◆ _location [1/2]

str generate_packets.Location._location
staticprotected

Definition at line 357 of file generate_packets.py.

◆ _location [2/2]

generate_packets.Location._location
protected

Definition at line 370 of file generate_packets.py.

◆ _PACKET [1/2]

str generate_packets.Location._PACKET = "#error gen_packet$"
staticprotected

Definition at line 352 of file generate_packets.py.

◆ _PACKET [2/2]

generate_packets.Location._PACKET
protected

Definition at line 432 of file generate_packets.py.

◆ depth [1/2]

int generate_packets.Location.depth
static

Definition at line 360 of file generate_packets.py.

◆ depth [2/2]

generate_packets.Location.depth

Definition at line 371 of file generate_packets.py.

◆ json_depth [1/2]

int generate_packets.Location.json_depth
static

Definition at line 363 of file generate_packets.py.

◆ json_depth [2/2]

generate_packets.Location.json_depth

Definition at line 372 of file generate_packets.py.

◆ name [1/2]

str generate_packets.Location.name
static

Definition at line 355 of file generate_packets.py.

◆ name [2/2]

generate_packets.Location.name

Definition at line 369 of file generate_packets.py.