Changelog#

More entries will be added in the future.

[2.6.3] - Patch#

Fixed#

caterpillar#

  • Fix various stub files and decorator annotations

[2.6.2] - Patch#

Fixed#

caterpillar.field._base#

  • Fix 1-length sized array fields

caterpillar#

  • Add compatibility with at least Python 3.10 by using typing_extensions

[2.6.1] - Hot-Fix#

Fixed#

caterpillar.fields._base#

  • Fix switch functionality within the Field class for ContextPath objects

caterpillar.fields.common#

  • fix % operator for the AsLengthRef class.

[2.6.0] - Minor Release#

Added#

caterpillar.fields._base#

  • Add support for non-context lambda switch fields

caterpillar.fields.common#

  • Add compatibility support for CAPI atoms in Int, UInt and PyStructFormattedField

  • Add new AsLengthRef class

caterpillar.options#

  • Add custom Flag.__eq__ implementation to support equality check with c_Option objects

caterpillar.abc#

  • Add new typing-only _OptionLike protocol

  • Add missing _SupportsType protocol to the stubs file

  • Add new method get to the _ContextLike protocol

caterpillar.context#

  • Add new option O_CONTEXT_FACTORY that controls the global context type. Value must be a method or another type implementing the _ContextLike protocol

  • Add new global context path: root (exported as G in shortcuts)

caterpillar.shortcuts#

CAPI#

  • New index assignment system when generating CAPI code. A running number is now applied instead of a hard coded index.

  • Add complete Context implementation in C (c_Context) that conforms to the _ContextLike protocol.

  • Add Atom for C-based struct-like classes. This class was previously known as catom

  • Add native support for __bits__ in Atom

  • Add special class LengthInfo for packing or unpacking multiple objects

  • New builtin atoms (CAPI): Repeated, Conditional and Switch

  • Add new shared objects and exception types to the native implementation (Cp_ContextFactory, Cp_ArrayFactory, CpExc_Stop and Cp_DefaultOption)

Changed#

caterpillar.fields._base#

  • Rework Field implementation to reduce overhead when packing and unpacking elements

  • Use pre-computed states instead of calculating everything on-the-fly. States will be adjusted when setting new values (automatically updated through @property attributes)

Fixed#

caterpillar.fields.common#

  • Fix issue in Prefixed that occurred when the internal struct packs a sequence of elements

Removed#

CAPI#

  • Remove old CAPI and completely revamp the CAPI concept to make it compatible to the Python equivalent.

[2.5.1] - Hot-Fix Release#

Fixed#

caterpillar.model#

  • An issue when packing or unpacking a bitfield with unnamed fields AND S_DISCARD_UNNAMED enabled

[2.5.0] - Minor Release#

This version introduces massive changes due to the addition of stub files. Most of the type hints in the Python file are ported into several stub files. Additionally, the bitfield concept was completely renewed to be more flexible and dynamic.

Added#

caterpillar.abc#

caterpillar.shortcuts#

  • New shortcuts: typeof(), to_struct(), hasstruct(), getstruct() and sizeof()

caterpillar.shared#

  • New constants from other modules: ATTR_BYTEORDER, ATTR_TYPE, ATTR_BITS, ATTR_SIGNED, ATTR_TEMPLATE

caterpillar.context#

  • New context attribute: _root can be set to point to the root context instance. Internally, instead of a for-loop that iterates through parent context instances, a simple self.get(...) call is made.


Removed#

caterpillar.abc#

  • _Action protocol and create two separate Protocols that form:

    _ActionLike = _SupportsActionUnpack | _SupportsActionPack
    
  • __type__ requirement from _StructLike

  • Breaking: _EnumLike, _ContextPathStr

caterpillar.model#

  • Unused getformat function

caterpillar.fields.common#

  • Unused __fmt__ function in Transformer


Changed#

caterpillar.abc#

  • Rename _Switch protocol to _SwitchLike

  • Move the following attributes and methods into caterpillar.shared: rename STRUCT_FIELD to ATTR_STRUCT, hasstruct(), getstruct() and typeof()

caterpillar.byteorder#

  • Move BYTEORDER_FIELD to caterpillar.shared as ATTR_BYTEORDER

caterpillar.model#

  • sizeof() now checks if the provided object implements the _SupportsSize protocol

  • New Bitfield concept with enhanced syntax

Documentation#

  • Update reference and library docs as well as section numbering


Fixed#

caterpillar.model#

  • when parsing union objects with an unbound stream object

  • field options defined in Sequences and Structs were not populated when creating fields.