Byteorder and Architecture#

Byteorder#

class caterpillar.byteorder.ByteOrder(name: str, ch: str, alignment: Alignment = Alignment.NONE, size: Size = Size.STANDARD)[source]#

Represents byte order information, including alignment and size.

Parameters:
  • name – A string representing the name of the byte order.

  • ch – A string representing the character used to specify the byte order in struct format strings.

  • alignment – An enumeration representing the alignment (default is Alignment.NONE).

  • size – An enumeration representing the size (default is Size.STANDARD).

class Alignment(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
class Size(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
apply(other)[source]#

Applies the byte order information to another object.

Parameters:

other – The object to which the byte order information should be applied.

byteorder.BYTEORDER_FIELD = '__byteorder__'#
byteorder.Native = ByteOrder(name='Native', ch='=', alignment=<Alignment.NONE: 0>, size=<Size.STANDARD: 0>)#
byteorder.BigEndian = ByteOrder(name='Big Endian', ch='>', alignment=<Alignment.NONE: 0>, size=<Size.STANDARD: 0>)#
byteorder.LittleEndian = ByteOrder(name='Little Endian', ch='<', alignment=<Alignment.NONE: 0>, size=<Size.STANDARD: 0>)#
byteorder.NetEndian = ByteOrder(name='Network', ch='!', alignment=<Alignment.NONE: 0>, size=<Size.STANDARD: 0>)#
byteorder.SysNative = ByteOrder(name='SysNative', ch='@', alignment=<Alignment.NATIVE: 1>, size=<Size.NATIVE: 1>)#
caterpillar.byteorder.byteorder(obj, default: ByteOrder = None) ByteOrder[source]#

Get the byte order of an object, defaulting to SysNative if not explicitly set.

Parameters:

obj – The object to retrieve the byte order from.

Returns:

The byte order of the object.

Architecture#

class caterpillar.byteorder.Arch(name: str, ptr_size: int)[source]#

Represents a system architecture with a name and an indication of whether it is 64-bit.

Parameters:
  • name – The name of the architecture.

  • ptr_size – the amount of bits one pointer takes

byteorder.system_arch: Arch = Arch(name='x86_64', ptr_size=64)#