This release will introduce breaking changes in the C API of this project, reducing the overhead of CpFieldObject and
splitting the monolithic parsing functions.
Tasks
[ ] Write tests for all implemented C atoms and builtin atoms
[ ] Add documentation for all new C atoms
[ ] Add benchmarks
What's changed
The native module (caterpillar._C) can be installed via pip without the environment variable present:
CpLazyAtomObject: forward references to atoms (Python type:lazy`)
CpCStringAtomObject: C-Strings with variable padding character (Python type:cstring`)
The following C atoms have been renamed:
CpIntAtomObject: Python Type int_t -> Int
CpPaddingAtomObject: Python Type padding_t -> Padding
CpFloatAtomObject: Python Type float_t -> Float
CpCharAtomObject: Python Type char_t -> Char
CpBoolAtomObject: Python Type bool_t -> Bool
There are now two python modules which import all available classes at once. They can be accessed via their
language tag (Both implementations are not compatible to each other):
from caterpillar.c import *
from caterpillar.py import *
A new unique feature was added to the C module to be able to map Python types to atom types. Using the TYPE_MAP one can configure a mapping between a native Python type and its corresponding atom representation:
from caterpillar.c import *
TYPE_MAP[int] = u32
@struct
class Format:
value: int # now we can simply use int
How the C API headers are generated has changed:
All API functions, types, objects and source files are placed into src/capi.dat using the following schema:
type:INDEX:STRUCT_NAME:TYPEDEF_NAME:CAPI_TYPE
Defines a C API type for a C structure. The index is optional and the CAPI_TYPE will be inferred as PyTypeObject if none set
obj:INDEX:NAME:TYPE
Defines a C API object.
func:INDEX:NAME:RETURN_TYPE:REFCOUNT
Defines a C API function. The function must be present within the source set of this file.
src:FILE
Defines the source file (relative to this file) that contains the function definitions.
The following changes have been made to the C API:
Minor Release 2.2.0 breaking changes
This release will introduce breaking changes in the C API of this project, reducing the overhead of
CpFieldObject
and splitting the monolithic parsing functions.Tasks
What's changed
The native module (
caterpillar._C
) can be installed via pip without the environment variable present:The following new C atoms have been added/implemented:
CpBuiltinAtomObject
: Base class for all standard atoms (C-layer) (Python Type:builtinatom
)CpRepeatedAtomObject
: essentially a sequence of atoms (Python Type:repeated
)CpConditionAtomObject
: adds a condition to the target atom (Python Type:conditional
)CpSwitchAtomObject
: simulates a switch statement (Python Type:switch
)CpOffsetAtomObject
: places the atom at a specific offset (Python Type:atoffset
)CpPrimitiveAtomObject
: same asbuiltinatom
but for Python classes (Python Type:patom
)CpBytesAtomObject
: equivalent ofcaterpillar.py.Bytes
(Python Type:octetstring
)CpPStringAtomObject
: Pascal-String implementation (Python Type:pstring
)CpConstAtomObject
: constant expressions (Python Type:const
)CpEnumAtomObject
: support forenum.Enum
types (Python Type:enumeration
)CpVarIntAtomObject
: little endian and big endian variable-length integer objects (Python Type:VarInt
)CpComputedAtomObject
: constant expressions (Python type:computed
): forward references to atoms (Python type:
lazy`): C-Strings with variable padding character (Python type:
cstring`)The following C atoms have been renamed:
CpIntAtomObject
: Python Typeint_t
->Int
CpPaddingAtomObject
: Python Typepadding_t
->Padding
CpFloatAtomObject
: Python Typefloat_t
->Float
CpCharAtomObject
: Python Typechar_t
->Char
CpBoolAtomObject
: Python Typebool_t
->Bool
There are now two python modules which import all available classes at once. They can be accessed via their language tag (Both implementations are not compatible to each other):
A new unique feature was added to the C module to be able to map Python types to atom types. Using the
TYPE_MAP
one can configure a mapping between a native Python type and its corresponding atom representation:How the C API headers are generated has changed:
src/capi.dat
using the following schema:The following changes have been made to the C API: