- New concept: extended syntax featuring typing compliance; introduces shortcut
fto annotate fields andInvisible()to hide fields from the constructor struct_factory.mixinandbitfield_factory.mixinboth provide default function wrappers for packing and unpacking data as well as typing fixes for operating on types directly.- New
parentctxcontext path - Dynamic endian is now used by default (i. e. can be changed via order parameter in pack() or unpack())
- New generic
Timestampclass - A number of new test cases
- New module:
caterpillar.types: defines default types that can be used as annotations within struct definitions O_DEFAULT_ENDIANas a global option to set a global default byteorderO_DEFAULT_ARCHsame concept for arch-like objects- new 'strict' option to
Enumstruct ATTR_PACKandATTR_UNPACKto caterpillar.shared'order'and'arch'options to pack() and unpack(), which temporarily change the global endianess or arch (compatible with Dynamic byteorder)
- Merge all stub files with their corresponding Python files. All typing is now inline.
paddingstruct now has its own dedicated class- sizeof() now always returns an integer
- ContextPath: dropped support for the call action
- Field.get_name() now always returns a string
- Rename
ssizeandsizetopssizeandpsizein caterpillar.fields exports - options.get_flags() always returns a list
- IntFlag support for
Enumstructs - Fix incorrect Sha1 Digest length
- Add missing global exports in
caterpillar.py - Bitfield, Struct and Sequence now respect fields with already configured byteorder
- Prefixed struct now does not require
as_field=Truewhen calling pack() or unpack()
- New concept: dynamic byte order (explained in documentation "Dynamic Byte Order")
caterpillar.field.net
- Fixed parsing of :class:
~caterpillar.fields.net.MACAddress - Fixed mixed endian in a struct, sequence or bit-field
caterpillar
- Various stub files and decorator annotations
caterpillar.field._base
- Fix 1-length sized array fields
caterpillar
- Add compatibility with at least Python 3.10 by using
typing_extensions
-
caterpillar.fields._base
- Fix switch functionality within the
Fieldclass forContextPathobjects
- Fix switch functionality within the
-
caterpillar.fields.common
- fix
%operator for theAsLengthRefclass.
- fix
-
caterpillar.fields._base
- Add support for non-context lambda switch fields.
-
caterpillar.fields.common
- Add compatibility support for CAPI atoms in
Int,UIntandPyStructFormattedField.
- Add compatibility support for CAPI atoms in
-
caterpillar.options
- Add custom
Flag.__eq__implementation to support equality check withc_Optionobjects.
- Add custom
-
caterpillar.abc
- Add new typing-only
_OptionLikeprotocol. - Add missing
_SupportsTypeprotocol to the stubs file. - Add new method
getto the_ContextLikeprotocol.
- Add new typing-only
-
caterpillar.context
- Add new option
O_CONTEXT_FACTORYthat controls the global context type. Value must be a method or another type implementing the_ContextLikeprotocol. - Add new global context path:
root(exported asGin shortcuts).
- Add new option
-
caterpillar.shortcuts
- Add new shortcuts
Cforctx,PforparentandGfor therootcontext asContextPathobjects.
- Add new 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_ContextLikeprotocol. - Add
Atomfor C-based struct-like classes (previously known ascatom). - Add native support for
__bits__inAtom. - Add special class
LengthInfofor packing or unpacking multiple objects. - New builtin atoms (CAPI):
Repeated,ConditionalandSwitch. - Add new shared objects and exception types to the native implementation (
Cp_ContextFactory,Cp_ArrayFactory,CpExc_StopandCp_DefaultOption).
- caterpillar.fields._base
- Rework
Fieldimplementation to reduce overhead when packing and unpacking elements. - Use pre-computed states instead of calculating everything on the fly; states will be adjusted automatically when setting new values (via
@propertyattributes).
- Rework
- caterpillar.fields.common
- Fix issue in
Prefixedthat occurred when the internal struct packs a sequence of elements.
- Fix issue in
- CAPI
- Remove old CAPI and completely revamp the CAPI concept to make it compatible with the Python equivalent.
- caterpillar.model
- An issue when packing or unpacking a bitfield with unnamed fields AND
S_DISCARD_UNNAMEDenabled
- An issue when packing or unpacking a bitfield with unnamed fields AND
-
caterpillar.abc
- Add
_SupportsBitsprotocol. - Add
_ContainsBitsprotocol. - Add
_SupportsTypeprotocol.
- Add
-
caterpillar.shortcuts
- Add new shortcuts:
typeof,to_struct,hasstruct,getstruct, andsizeof.
- Add new shortcuts:
-
caterpillar.shared
- Add new constants from other modules:
ATTR_BYTEORDER,ATTR_TYPE,ATTR_BITS,ATTR_SIGNED,ATTR_TEMPLATE.
- Add new constants from other modules:
-
caterpillar.context
- Add context attribute
_rootto point to the root context instance. Internal parent iteration now usesself.get(...).
- Add context attribute
-
caterpillar.abc
- Remove
_Actionprotocol; split into_ActionLike = _SupportsActionUnpack | _SupportsActionPack. - Remove
__type__requirement from_StructLike. - Breaking: Remove
_EnumLikeand_ContextPathStr.
- Remove
-
caterpillar.model
- Remove unused
getformatfunction.
- Remove unused
-
caterpillar.fields.common
- Remove unused
__fmt__function inTransformer.
- Remove unused
-
caterpillar.abc
- Rename
_Switchprotocol to_SwitchLike. - Move
STRUCT_FIELDtocaterpillar.sharedasATTR_STRUCT; movehasstruct,getstruct, andtypeoftocaterpillar.shared.
- Rename
-
caterpillar.byteorder
- Move
BYTEORDER_FIELDtocaterpillar.sharedasATTR_BYTEORDER.
- Move
-
caterpillar.model
- Update
sizeofto check if the object implements_SupportsSizeprotocol. - Renew
Bitfieldconcept with enhanced syntax.
- Update
-
Documentation
- Update reference and library docs; improve section numbering.
- caterpillar.model
- Fix parsing of union objects with an unbound stream.
- Fix field options in Sequences and Structs not being populated when creating fields.